Adding data to a table

To add data to a table, use the INSERT command. Let’s see this in action by populating the table classics with the data, using one form of the INSERT command repeatedly.

INSERT INTO classics(author, title, type, year)
VALUES('Mark Twain','The Adventures of Tom Sawyer','Fiction','1876');

INSERT INTO classics(author, title, type, year)
VALUES('Jane Austen','Pride and Prejudice','Fiction','1811');

INSERT INTO classics(author, title, type, year)
VALUES('Charles Darwin','The Origin of Species','Non-Fiction','1856');

INSERT INTO classics(author, title, type, year)
VALUES('Charles Dickens','The Old Curiosity Shop','Fiction','1841');

INSERT INTO classics(author, title, type, year)
VALUES('William Shakespeare','Romeo and Juliet','Play','1594');

After every second line, you should see a “Query OK” message. Once all lines have been entered, type the following command, which will display the table’s contents.

SELECT * FROM classics;