Sql - INSERT INTO
Code Life
By Pierre Marsaa
Adding a row
Until now you have only read data. INSERT INTO adds a row: name the table, list the columns you fill, then give one value per column, in the same order.
Run it — the SELECT at the end shows the result:
↗️
Loading editor...
↶
↷
Casey is the fifth row. You did not give a trainer_id: the column is an INTEGER PRIMARY KEY, so the database numbers the row itself.
Text goes in single quotes, numbers are written bare.
Your sandbox resets on every run
In CodeLife, to simplify learning, each run starts from the original data: your changes last until the end of the run. That is why every example ends with a SELECT — it is the only way to see what you did. Run the example twice: still one Casey, no duplicate.
Verify