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,
- priority integer default '1' not null,
- created_at timestamp not null,
- completed_at timestamp);
- CREATE TABLE
- Branderson=# select * from todos;
- insert into todos (title, details, priority, created_at, completed_at)
- values
- ('walk dog', 'walk the damn dog', 1, current_timestamp, current_timestamp);
- INSERT 0 1
- insert into todos (title, details, priority, created_at)
- values
- ('read a book', 'do a report...get a buck', 4, current_timestamp),
- ('watch farscape', 'binge watch in my undies', 2, current_timestamp),
- ('drink water', 'everyday', 1, current_timestamp),
- ('be awesome', 'as usual', 100, current_timestamp);
- INSERT 0 4
- select * from todos;
- select from todos where completed_at is null;
- --
- (8 rows)
- select from todos where priority > 1;
- --
- (6 rows)
- update todos set completed_at = current_timestamp where id = 4;
- UPDATE 1
- select * from todos where id = 4;
- delete from todos where completed_at is null;
- DELETE 7
- select * from todos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement