Skip to content

Instantly share code, notes, and snippets.

@takaram
Last active March 23, 2020 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaram/11fa8320bf6bc682abbaa7a42680f775 to your computer and use it in GitHub Desktop.
Save takaram/11fa8320bf6bc682abbaa7a42680f775 to your computer and use it in GitHub Desktop.
CREATE TABLE employees (
id serial primary key, -- ID
name text, -- 名前
join_year integer, -- 入社年
department_id integer -- 所属部署ID
);
CREATE TABLE departments (
id serial primary key, -- ID
name text -- 部署名
);
INSERT INTO departments (name)
SELECT format('営業%s課', i) FROM generate_series(1, 500) i;
INSERT INTO departments (name)
SELECT format('開発%s課', i) FROM generate_series(1, 500) i;
INSERT INTO employees (name, join_year, department_id)
SELECT format('社員%s', i), 2000 + (random() * 20)::integer, i % 1000 + 1 FROM generate_series(1, 50000) i;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment