Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. CREATE TABLE todo(
  2. id SERIAL PRIMARY KEY,
  3. title VARCHAR(255) NOT NULL,
  4. details VARCHAR(8000) NULL,
  5. priority INTEGER NOT NULL DEFAULT '1',
  6. created_at TIMESTAMP NOT NULL,
  7. completed_at TIMESTAMP NULL,
  8. );
  9.  
  10. INSERT INTO todo (title, priority, created_at, completed_at) VALUES ('Clean the garage', 2, current_timestamp, current_timestamp);
  11.  
  12. INSERT INTO todo (title, priority, created_at) VALUES ('Poop scoop', 3, current_timestamp);
  13.  
  14. INSERT INTO todo (title, priority, created_at) VALUES ('Feed pets', 1, current_timestamp);
  15.  
  16. INSERT INTO todo (title, priority, created_at) VALUES ('Smell the roses', 2, current_timestamp);
  17.  
  18. INSERT INTO todo (title, priority, created_at) VALUES ('Fight the zombies', 1, current_timestamp);
  19.  
  20. SELECT * FROM todo WHERE completed_at IS NULL;
  21.  
  22. SELECT * FROM todo WHERE priority > 1;
  23.  
  24. UPDATE todo SET completed_at = current_timestamp WHERE id = 148;
  25.  
  26. DELETE FROM todo WHERE completed_at IS NOT NULL;
  27.  
  28. SELECT * FROM todo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement