INSERT All Values: Chapter 2: Inserting
INSERT All Values: Chapter 2: Inserting
INSERT All Values: Chapter 2: Inserting
Note: You can insert rows into a view if that view qualifies as an updatable
view and it involves only one table. For more information about updatable views,
see Section 3.23, CREATE VIEW.
The expressions in the VALUES list must appear in the same order as the col-
umns to which they apply appear in the CREATE TABLE. Also, you must
specify a value for every single column in the table.
In the following example the value 1 is placed in key_1, 'first row' goes in
non_key_1, and '2003 09 29 13:21' is placed in last_updated:
CREATE TABLE t1 (
key_1 INTEGER NOT NULL DEFAULT AUTOINCREMENT,
non_key_1 VARCHAR ( 100 ) NOT NULL,
last_updated TIMESTAMP NOT NULL DEFAULT TIMESTAMP,
PRIMARY KEY ( key_1 ) );
Tip: To see the order of columns in a table called t1, run this command in
ISQL: SELECT * FROM t1 WHERE 1 = 0. It will display the column names without
retrieving any data. Dont worry about performance this query will always run
quickly no matter how big the table is because the database engine knows that
WHERE 1 = 0 means no rows will ever be returned.