Skip to content

Instantly share code, notes, and snippets.

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 duongphuhiep/ee14af3f783f5abedce274beebd903e5 to your computer and use it in GitHub Desktop.
Save duongphuhiep/ee14af3f783f5abedce274beebd903e5 to your computer and use it in GitHub Desktop.
POC cockroachdb
IMPORT TABLE wallet (
id bigserial primary key,
name text not null,
gender int,
email text,
first_name text,
last_name text,
creation_date timestamp not null,
situation int,
balance decimal not null,
is_blocked bool
) CSV DATA ('http://nginx/wallet-1M.csv') WITH skip='1', nullif='';
CREATE INDEX ON wallet(name);
CREATE INDEX ON wallet(situation);
CREATE INDEX ON wallet(is_blocked);
CREATE INDEX ON wallet(balance);
IMPORT TABLE transaction (
id bigserial primary key,
sender_id bigint,
receiver_id bigint,
amount decimal not null,
creation_date timestamp not null,
last_update timestamp,
schedule_date timestamp,
status int,
comment text,
linked_trans_id bigint,
c1 text,
c2 text,
c3 text
) CSV DATA ('http://nginx/transaction-15M.csv') WITH skip='1', nullif='';
CREATE INDEX ON transaction(sender_id);
CREATE INDEX ON transaction(receiver_id);
CREATE INDEX ON transaction(linked_trans_id);
ALTER TABLE transaction ADD CONSTRAINT sender_fk FOREIGN KEY (sender_id) REFERENCES wallet(id) ON DELETE CASCADE;
ALTER TABLE transaction ADD CONSTRAINT receiver_fk FOREIGN KEY (receiver_id) REFERENCES wallet(id) ON DELETE CASCADE;
ALTER TABLE transaction ADD CONSTRAINT linked_trans_fk FOREIGN KEY (linked_trans_id) REFERENCES transaction(id) ON DELETE CASCADE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment