Last active
October 31, 2023 21:14
-
-
Save tadeaspetak/6c585a483596837601975f93ac9f519b to your computer and use it in GitHub Desktop.
postgres-dataset
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
-- utility function for returning a random string of the given length | |
CREATE OR REPLACE FUNCTION random_string (string_length integer DEFAULT 10) | |
RETURNS varchar AS $$ | |
SELECT array_to_string( | |
ARRAY( | |
SELECT chr((65 + round(random() * 25))::integer) | |
FROM generate_series(1, string_length) | |
), '') $$ | |
LANGUAGE SQL; | |
-- create our sample users table | |
CREATE TABLE users ( | |
id serial PRIMARY KEY, | |
email varchar NOT NULL, | |
name varchar NOT NULL, | |
about varchar | |
); | |
-- populate with plenty of random data | |
INSERT INTO users (name, email, about) | |
SELECT | |
'email-' || random_string (5), | |
'name-' || random_string (5), | |
'about-' || random_string (30) | |
FROM generate_series(1, 100000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment