Last active
September 19, 2019 04:53
-
-
Save hadihammurabi/07186db8df0a718df4d35a078f4344a6 to your computer and use it in GitHub Desktop.
PostgreSQL Sharding with Declarative Partition Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TYPE jeniskelamin AS ENUM('l', 'p'); | |
CREATE TABLE users ( | |
username VARCHAR(255) NOT NULL, | |
password VARCHAR(255) NOT NULL, | |
jk jeniskelamin NOT NULL | |
) PARTITION BY LIST(jk); | |
CREATE TABLE users_l PARTITION OF users FOR VALUES IN('l'); | |
CREATE TABLE users_p PARTITION OF users FOR VALUES IN('p'); | |
INSERT INTO users VALUES ('hadihammurabi', '123123aaa', 'l'); | |
SELECT * FROM users; | |
SELECT * FROM users_l; | |
SELECT * FROM users_p; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment