SQLancer
LESSON 13

SQL (Core) - Inserting rows

Progress: 0%

SQL Lesson 13: Inserting rows

So far, we have only queried existing data from database tables. In this lesson, we will learn how to add brand new records using the INSERT INTO statement.

Insert Statement Syntax

To insert new rows into a database table, you specify the target table name, optionally list column names, and provide corresponding values:

INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);

If you supply values for every single column in the exact order specified by the table schema, you can omit the explicit column list:

INSERT INTO table_name
VALUES (val1, val2, val3, ...);
💡

Inserting Multiple Rows

INSERT INTO movies (title, director, year, length_minutes)
VALUES ('Toy Story 4', 'Josh Cooley', 2019, 100);

🗄️ Schema Explorer SELECTABLE

movies
|

🎯 Exercises Checklist:

1. Add the studio's new movie Toy Story 4 directed by Josh Cooley released in 2019 (length 100 min)
2. Add the boxoffice record for movie_id 15 with rating 8.7, domestic sales 340000000 and international sales 730000000
⚡ Practice Console

Data Output

No results. Run query to fetch data.

Current Task Target

5 rows