Adding New Rows: INSERT

The INSERT statement allows you to add rows to the database in two ways:

  • With the VALUES keyword

  • With a SELECT statement

Inserting Data into All Columns with VALUES

The VALUES keyword specifies data values for some or all of the columns in a new row. A generalized version of the syntax for the INSERT command using the VALUES keyword is the following:

INSERT INTO table_name [(column1 [, column2]...)]
VALUES (constant1 [, constant2]...)

This INSERT statement adds a new row to the publishers table, giving a value for every column in the row:

SQL
insert into publishers
values ('1622', 'Jardin, Inc.', '5 5th Ave.', 'Camden', 'NJ')

Notice that you have to type the data values in the same order as the column names in the original ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.