Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. create table todos
  2. (id serial primary key,
  3. title varchar(255) not null,
  4. details text,
  5. priority integer default '1' not null,
  6. created_at timestamp not null,
  7. completed_at timestamp);
  8. CREATE TABLE
  9. Branderson=# select * from todos;
  10. insert into todos (title, details, priority, created_at, completed_at)
  11. values
  12. ('walk dog', 'walk the damn dog', 1, current_timestamp, current_timestamp);
  13. INSERT 0 1
  14. insert into todos (title, details, priority, created_at)
  15. values
  16. ('read a book', 'do a report...get a buck', 4, current_timestamp),
  17. ('watch farscape', 'binge watch in my undies', 2, current_timestamp),
  18. ('drink water', 'everyday', 1, current_timestamp),
  19. ('be awesome', 'as usual', 100, current_timestamp);
  20. INSERT 0 4
  21. select * from todos;
  22. select from todos where completed_at is null;
  23.  
  24. --
  25. (8 rows)
  26.  
  27. select from todos where priority > 1;
  28. --
  29. (6 rows)
  30.  
  31. update todos set completed_at = current_timestamp where id = 4;
  32. UPDATE 1
  33. select * from todos where id = 4;
  34. delete from todos where completed_at is null;
  35. DELETE 7
  36. select * from todos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement