Skip to content

Instantly share code, notes, and snippets.

@handuy
Last active September 16, 2018 14:34
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/e88b2284c4480a60e8464e6ac0417f76 to your computer and use it in GitHub Desktop.
Save handuy/e88b2284c4480a60e8464e6ac0417f76 to your computer and use it in GitHub Desktop.
Cú pháp chạy: psql -U postgres -f [tên_file]. Chạy file 2.sql ở citus_master, 2_test.sql ở citus_worker_1
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS posts;
DROP SCHEMA IF EXISTS course CASCADE;
CREATE SCHEMA course;
CREATE TABLE users (id int, name text, age int);
CREATE TABLE posts (id int, title text);
CREATE TABLE course.lessons (id int, title text, point int);
SELECT create_reference_table('users');
SELECT create_reference_table('posts');
SELECT create_reference_table('course.lessons');
INSERT INTO users VALUES (1, 'Duy', 26), (2, 'Long', 24), (3, 'Huy', 28);
INSERT INTO posts VALUES (1, 'Hello World'), (2, 'Hello Citus'), (3, 'Hello Vietnam');
INSERT INTO course.lessons VALUES (1, 'Java', 10), (2, 'HTML', 20), (3, 'CSS', 40);
UPDATE users SET name = 'Cuong' WHERE id = 3;
DELETE FROM posts WHERE id = 3;
UPDATE course.lessons SET title = 'Javascript' WHERE id = 1;
SELECT * FROM users;
SELECT * FROM posts;
SELECT * FROM course.lessons;
\d
SELECT * FROM posts_102011;
SELECT * FROM users_102010;
select * from course.lessons_102021;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment