Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. -- createdb todolist
  2.  
  3. CREATE TABLE todos (
  4. id SERIAL PRIMARY KEY,
  5. title VARCHAR(250),
  6. details VARCHAR NULL,
  7. priority INTEGER DEFAULT 1.0,
  8. created_at TIMESTAMP,
  9. completed_at TIMESTAMP NULL
  10. );
  11.  
  12. INSERT INTO todos (title, details, priority, created_at, completed_at) VALUES ('Start learning how to code', 'Start learning how to code in front and back end engineering at The Iron Yard', 5, TIMESTAMP, DATE + TIME);
  13.  
  14. INSERT INTO todos (title, details, created_at, priority) VALUES ('Learn the basics of HTML', 'Learn enough to create a basic HTML webpage', TIMESTAMP, 3);
  15.  
  16. INSERT INTO todos (title, details, created_at, priority) VALUES ('Learn the basics of CSS', 'Learn enough to style your basic HTML webpage', TIMESTAMP, 3);
  17.  
  18. INSERT INTO todos (title, details, created_at, priority) VALUES ('Learn the basics of JavaScript', 'Learn enough JavaScript to make a basic web program that allows a user to make a todo list', TIMESTAMP, 3);
  19.  
  20. INSERT INTO todos (title, details, created_at, priority) VALUES ('Graduate from The Iron Yard', 'Put all of your skills together and graduate and find yourself a junior dev job', TIMESTAMP, 5);
  21.  
  22. SELECT * FROM todos WHERE completed_at IS NULL;
  23.  
  24. SELECT * FROM todos WHERE priority > 1;
  25.  
  26. UPDATE todos SET completed_at = TIMESTAMP WHERE id = 3;
  27.  
  28. DELETE FROM todos WHERE completed_at IS NOT NULL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement