Name
INSERT
Synopsis
The INSERT
statement adds rows of data to a table or view. The
INSERT statement allows records to be entered
into a table through one of several methods:
The first method is to insert records using the
DEFAULTvalues created on the columns given table via theCREATE TABLEorALTER TABLEstatements. (This method is not supported by Oracle.)The second and most common method is to declare the actual values to be inserted into each column of the record.
The third method, which quickly populates a table with many records, is to insert the result set of a
SELECTstatement into a table.
|
Vendor |
Command |
|---|---|
|
SQL Server |
Supported, with variations |
|
MySQL |
Supported, with variations |
|
Oracle |
Supported, with variations |
|
PostgreSQL |
Supported |
SQL99 Syntax and Description
INSERT [INTO] [[database_name.]owner.] {table_name | view_name} [(column_
list)]
{[DEFAULT] VALUES | VALUES (value[,...]) | SELECT_statement }To use the INSERT statement, first declare the
table (or view) where the data is to be inserted. The
INTO keyword is optional. Specify the columns in
the table that receives data by enclosing them in parentheses
separated by commas in the column_list. The
column_list can be left off, but all columns
that are defined for the table are then assumed.
The DEFAULT VALUES method is mutually exclusive
from the list_of_values and
SELECT_statement methods.
The INSERT . . . VALUES statement adds a single
row of data to a table using literal values supplied in the
statement. The
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access