Hone

Lessons · SQL · INSERT

Adding a row

INSERT INTO table (columns) VALUES (values), in the same order.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

Every form submission and import ends here.

How to think about it

Which columns, in which order? Always list the columns. A table gains a column later and the unlisted INSERT breaks.

Worked example

INSERT INTO films (title, year, minutes)
Named columns.
VALUES ('Arrival', 2016, 116);
Same order.

Your turn

Insert a director.

INSERT INTO directors (name)  ('Villeneuve');

The trap

Quoting numbers or not quoting text. SQLite is lenient; most databases are not.

Next in SQL

Every SQL lesson on one page

Practise INSERT on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.

SQLite is a registered trademark of Hipp, Wyrick & Company, Inc. Hone is not affiliated with or endorsed by them.