Skip to content

Instantly share code, notes, and snippets.

@handuy
Created September 16, 2018 15:09
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 handuy/04129ae754b3d7d171a5744a07f6bc16 to your computer and use it in GitHub Desktop.
Save handuy/04129ae754b3d7d171a5744a07f6bc16 to your computer and use it in GitHub Desktop.
Cú pháp chạy: psql -U postgres -f [tên_file]. Chạy ở citus_master
DROP TABLE IF EXISTS users CASCADE;
DROP TABLE IF EXISTS posts CASCADE;
DROP SCHEMA IF EXISTS course CASCADE;
CREATE TABLE users (id int PRIMARY KEY, name text, age int);
CREATE TABLE posts (id int PRIMARY KEY, title text, author_id int REFERENCES users(id));
ALTER TABLE posts DROP CONSTRAINT posts_author_id_fkey;
SELECT create_reference_table('users');
SELECT create_reference_table('posts');
ALTER TABLE posts ADD CONSTRAINT posts_author_id_fkey FOREIGN KEY (author_id) REFERENCES users (id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment