Oracle 5.0 Reference Manual page 1087

Table of Contents

Advertisement

INSERT INTO
tbl_name
But the following is not legal, because the value for
col1:
INSERT INTO
tbl_name
One exception involves columns that contain
value is generated after other value assignments, any reference to an
AUTO_INCREMENT
column in the assignment returns a 0.
AUTO_INCREMENT
statements that use
INSERT
of column values, each enclosed within parentheses and separated by commas. Example:
INSERT INTO
tbl_name
(a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
The values list for each row must be enclosed within parentheses. The following statement is illegal
because the number of values in the list does not match the number of column names:
INSERT INTO
tbl_name
(a,b,c) VALUES(1,2,3,4,5,6,7,8,9);
is a synonym for
VALUE
lists, and either may be used whether there is a single values list or multiple lists.
The affected-rows value for an
(see
Section 12.13, "Information
Section 20.6.6.1,
"mysql_affected_rows()").
If you use an
INSERT ... VALUES
statement returns an information string in this format:
Records: 100 Duplicates: 0 Warnings: 0
indicates the number of rows processed by the statement. (This is not necessarily the
Records
number of rows actually inserted because
number of rows that could not be inserted because they would duplicate some existing unique index
value.
indicates the number of attempts to insert column values that were problematic in
Warnings
some way. Warnings can occur under any of the following conditions:
• Inserting
into a column that has been declared
NULL
statements or
INSERT INTO ... SELECT
value for the column data type. This is
and the "zero" value for date and time types.
the same way as multiple-row inserts because the server does not examine the result set from the
to see whether it returns a single row. (For a single-row INSERT, no warning occurs when
SELECT
is inserted into a
NULL
• Setting a numeric column to a value that lies outside the column's range. The value is clipped to the
closest endpoint of the range.
• Assigning a value such as
off and the remaining numeric part is inserted. If the string value has no leading numeric part, the
column is set to 0.
• Inserting a string into a string column (CHAR, VARCHAR, TEXT, or BLOB) that exceeds the column's
maximum length. The value is truncated to the column's maximum length.
• Inserting a value into a date or time column that is illegal for the data type. The column is set to the
appropriate zero value for the type.
If you are using the C API, the information string can be obtained by invoking the
function. See
Section 20.6.6.35,
Syntax
INSERT
(col1,col2) VALUES(15,col1*2);
(col1,col2) VALUES(col2*2,15);
syntax can insert multiple rows. To do this, include multiple lists
VALUES
in this context. Neither implies anything about the number of values
VALUES
can be obtained using the
INSERT
Functions"), or the
statement with multiple value lists or
Duplicates
statements, the column is set to the implicit default
for numeric types, the empty string ('') for string types,
0
INSERT INTO ... SELECT
column. Instead, the statement fails with an error.)
NOT NULL
to a numeric column. The trailing nonnumeric text is stripped
'10.34 a'
"mysql_info()".
1067
refers to col2, which is assigned after
col1
values. Because the
AUTO_INCREMENT
ROW_COUNT()
mysql_affected_rows()
can be nonzero.)
NULL. For multiple-row
NOT
[963]
function
C API function (see
SELECT, the
INSERT ...
indicates the
Duplicates
INSERT
statements are handled
mysql_info()

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents