Adds new rows to a table or view.
insert [into] [database.[owner.]]{table_name|view_name} [(column_list)] {values (expression [, expression]...) |select_statement [plan "abstract plan"]}
The column list is necessary when some, but not all, of the columns in the table are to receive data. If no column list is given, the SAP ASE server assumes that the insert affects all columns in the receiving table (in create table order).
You cannot use a subquery as an expression.
The values list:
Must be enclosed in parentheses
Must match the explicit or implicit column list
Can use “default” as a value
See System and User-Defined Datatypes in Reference Manual: Building Blocks for more information about data entry rules.
insert titles values ("BU2222", "Faster!", "business", "1389", null, null, null, "ok", "06/17/87", 0)
insert titles (title_id, title, type, pub_id, notes, pubdate, contract) values ('BU1237', 'Get Going!', 'business', '1389', 'great', '06/18/86', 1)
insert newauthors select * from authors where city = "San Francisco"
insert test select * from test where city = "San Francisco"
insert table1 (col1, col2, col3, col4) values (10, 4, default, 34)
Use insert only to add new rows. Use update to modify column values in a row you have already inserted.
When inserting into text, unitext, and image columns, an insert of a NULL into a text , ortext, or an image column simply allocates space for a text pointer. Use update to get a valid text pointer for that column.
You can define a trigger that takes a specified action when an insert command is issued on a specified table.
You can send an insert as a language event or as a parameterized dynamic statement to remote servers.
System and User-Defined Datatypes in Reference Manual: Building Blocks
sp_bindefault, sp_bindrule, sp_help, sp_helpartition, sp_unbindefault, sp_unbindrule in Reference Manual: Procedures
bcp in the Utility Guide
ANSI SQL – Compliance level: Entry-level compliant.
The following are Transact-SQL extensions:
A union operator in the select portion of an insert statement.
Qualification of a table or column name by a database name.
Insertion through a view that contains a join.
The permission checks for insert differ based on your granular permissions settings.
Setting | Description |
---|---|
Enabled | With granular permissions enabled, you must be the table owner or a user with insert permissionon the table. Only the table owner or user with insert and identity_insert permissions can insert for the table's IDENTITY column. |
Disabled | With granular permissions disabled, you must be the table owner or a user with sa_role. insert permission defaults to the table owner. insert permission for a table’s IDENTITY column is limited to the table owner, database owner, and system administrator. |
Values in event and extrainfo columns of sysaudits are:
Information | Values |
---|---|
Event | 41 |
Audit option | insert |
Command or access audited | insert into a table |
Information in extrainfo |
|
Information | Values |
---|---|
Event | 42 |
Audit option | insert |
Command or access audited | insert into a view |
Information in extrainfo |
|