Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- createdb todolist
- CREATE TABLE todos (
- id SERIAL PRIMARY KEY,
- title VARCHAR(250),
- details VARCHAR NULL,
- priority INTEGER DEFAULT 1.0,
- created_at TIMESTAMP,
- completed_at TIMESTAMP NULL
- );
- 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);
- INSERT INTO todos (title, details, created_at, priority) VALUES ('Learn the basics of HTML', 'Learn enough to create a basic HTML webpage', TIMESTAMP, 3);
- INSERT INTO todos (title, details, created_at, priority) VALUES ('Learn the basics of CSS', 'Learn enough to style your basic HTML webpage', TIMESTAMP, 3);
- 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);
- 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);
- SELECT * FROM todos WHERE completed_at IS NULL;
- SELECT * FROM todos WHERE priority > 1;
- UPDATE todos SET completed_at = TIMESTAMP WHERE id = 3;
- DELETE FROM todos WHERE completed_at IS NOT NULL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement