Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE todos (
- id SERIAL PRIMARY KEY,
- title VARCHAR(255) NOT NULL,
- details TEXT NULL,
- priority INTEGER NOT NULL DEFAULT '1',
- created_at TIMESTAMP NOT NULL,
- completed_at TIMESTAMP NULL
- );
- INSERT INTO todos
- (title, details, priority, created_at, completed_at)
- VALUES
- ('wash car', 'clean this nice car', '1', current_timestamp, current_timestamp),
- ('walk dog', 'walk the bulldog', '3', current_timestamp, NULL),
- ('clean house', 'clean the whole thing', '4', current_timestamp, NULL),
- ('buy groceries', 'get healthy food', '5', current_timestamp, NULL),
- ('change oil', 'go to jiffy lube', '2', current_timestamp, NULL);
- select * from todos;
- SELECT * FROM todos WHERE completed_at IS NULL;
- SELECT * FROM todos WHERE priority > 1;
- UPDATE todos SET completed_at = current_timestamp WHERE priority = 4;
- select * from todos;
- DELETE FROM todos WHERE completed_at IS NOT NULL;
- select * from todos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement