Given this table:
CREATE TABLE users (id INTEGER, first_name TEXT, surname TEXT, salary INTEGER);
Insert 3 rows. Each row should have different unique id value, starting at 1 and increasing by 1 each time. Make up the other values, but make sure to use the correct type of data!
Given this table:
CREATE TABLE entries (content TEXT, publication_date TEXT);
Insert 2 rows with a different publication date. You can choose whatever format for the date you want, but be consistent! That's one of the most important things when working with databases.
Here's the solution for exercise 1:
INSERT INTO users VALUES (1, 'Rolf', 'Smith', 55000); INSERT INTO users VALUES (2, 'Bob', 'Smith', 45000); INSERT INTO users VALUES (3, 'Anne', 'Pun', 87000);
Here I've made up my own id values, starting at 1 and going up by 1. Later on we'll learn how to get SQLite (and PostgreSQL) to generate those numbers for us.
Also remember that strings should use single quotes!
Here's the solution for exercise 2:
INSERT INTO entries VALUES ('Today I learned about SQLite', '2020-06-01');
INSERT INTO entries VALUES ('I''ve continued to learn about SQLite!', '2020-06-02');Something interesting to note here is that in order to include the apostrophe in I've, in SQL you have to put two apostrophes: I''ve. That way, the apostrophe doesn't mean "terminate the string here", it just means "put an apostrophe inside the string here".