Created
August 4, 2019 12:43
-
-
Save trietphm/391a333e0488a2b9eaf5c0d30bd003ed to your computer and use it in GitHub Desktop.
Sample data for partial index
This file contains hidden or 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
DROP SEQUENCE seq1; | |
DROP SEQUENCE seq2; | |
DROP TABLE rdata; | |
CREATE SEQUENCE seq1; | |
CREATE SEQUENCE seq2; | |
CREATE TABLE rdata ( | |
id serial PRIMARY KEY NOT NULL, | |
name VARCHAR(255), | |
balance FLOAT, | |
unique_val1 INTEGER, | |
unique_val2 INTEGER, | |
registered BOOLEAN, | |
created_at DATE | |
); | |
INSERT INTO rdata(name, balance, unique_val1, unique_val2, registered, created_at) | |
SELECT | |
('{John,Harry,Bob,Alice,Wilson,Nick,Dave,dAve,DaVe}'::text[])[CEIL(random()*9)] AS name, | |
CEIL(random() * 10000) AS balance, | |
nextval('seq1')::int AS unique_val1, | |
nextval('seq2')::int AS unique_val2, | |
CEIL(random()*100) > 1 AS registered, | |
(now() + (CEIL(random() * 365) || ' day') :: INTERVAL)::date AS created_at | |
FROM generate_series(1,10000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment