Skip to content

Instantly share code, notes, and snippets.

@takaram takaram/has_many_test.sql
Last active Mar 23, 2020

Embed
What would you like to do?
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
You can’t perform that action at this time.