INSERT,
UPDATE, and
DELETE statements behave in an atomic manner. That is, if an insert, update, or delete of more than one row fails, then all insertions, updates, or deletes of previous rows by the same statement are rolled back.
You may use the variables CURTIME(), CURDATE() and NOW() in INSERT statements to insert the current
local date, time and timestamp values.
In order to insert the current UTC time, date, or timestamp using CURRENT_TIME() or related functions, you must structure your SQL statement as shown:
The following INSERT statement uses a
SELECT clause to retrieve from the Student table the ID numbers of students who have taken classes.
The following example shows what occurs when you use INSERT for IDENTITY columns and columns with default values.
The SELECT shows the table contains the following rows:
The first row illustrates that if “0” is specified in the values clause for an IDENTITY column, then the value inserted is “1” if the table is empty.
The first row also illustrates that if no value is specified in the values clause for a column with a default value, then the specified default value is inserted.
The second row illustrates that if “0” is specified in the values clause for an IDENTITY column, then the value inserted is one greater than the largest value in the IDENTITY column.
The second row also illustrates that if a value is specified in the values clause for a column with a default value, then the specified value overrides the default value.
The third row illustrates that if a value other than “0” is specified in the values clause for an IDENTITY column, then that value is inserted. If a row already exists that contains the specified value for the IDENTITY column, then the message “The record has a key field containing a duplicate value(Btrieve Error 5)” is returned and the
INSERT fails.
The fourth rows shows again that if “0” is specified in the values clause for an IDENTITY column, then the value inserted is one greater than the largest value in the IDENTITY column. This is true even if “gaps” exist between the values (that is, the absence of one or more rows with IDENTITY column values less than the largest value).
The fifth row illustrates that if no value is specified in the values clause for an IDENTITY column, then the value inserted is one greater than the largest value in the IDENTITY column.