Oracle 5.0 Reference Manual page 50

Table of Contents

Advertisement

other hand, is possible, as is a self-referential
be nested more than 15 levels deep.
• In an SQL statement that inserts, deletes, or updates many rows, foreign key constraints (like unique
constraints) are checked row-by-row. When performing foreign key checks,
level locks on child or parent records that it must examine. MySQL checks foreign key constraints
immediately; the check is not deferred to transaction commit. According to the SQL standard, the
default behavior should be deferred checking. That is, constraints are only checked after the entire
SQL statement has been processed. This means that it is not possible to delete a row that refers to
itself using a foreign key.
For information how
and
FOREIGN KEY
1.8.6.3. Constraints on Invalid Data
Before MySQL 5.0.2, MySQL is forgiving of illegal or improper data values and coerces them to legal
values for data entry. In MySQL 5.0.2 and up, that remains the default behavior, but you can change
the server SQL mode to select more traditional treatment of bad values such that the server rejects
them and aborts the statement in which they occur.
This section describes the default (forgiving) behavior of MySQL, as well as the strict SQL mode and
how it differs.
If you are not using strict mode, then whenever you insert an "incorrect" value into a column, such as
a
into a
NULL
column to the "best possible value" instead of producing an error: The following rules describe in more
detail how this works:
• If you try to store an out of range value into a numeric column, MySQL Server instead stores zero,
the smallest possible value, or the largest possible value, whichever is closest to the invalid value.
• For strings, MySQL stores either the empty string or as much of the string as can be stored in the
column.
• If you try to store a string that doesn't start with a number into a numeric column, MySQL Server
stores 0.
• Invalid values for
Constraints".
SET
• MySQL enables you to store certain incorrect date values into
as
'2000-02-31'
dates. If MySQL can store a date value and retrieve exactly the same value, MySQL stores it as
given. If the date is totally wrong (outside the server's ability to store it), the special "zero" date value
'0000-00-00'
• If you try to store
row
INSERT
statements, MySQL Server stores the implicit default value for the column data type. In general, this
is
for numeric types, the empty string ('') for string types, and the "zero" value for date and time
0
types. Implicit default values are discussed in
• If an
INSERT
column definition includes an explicit
MySQL inserts the implicit default value for the column data type.
The reason for using the preceding rules in nonstrict mode is that we can't check these conditions until
the statement has begun executing. We can't just roll back if we encounter a problem after updating
a few rows, because the storage engine may not support rollback. The option of terminating the
statement is not that good; in this case, the update would be "half done," which is probably the worst
How MySQL Deals with Constraints
foreign keys differ from the SQL standard, see
InnoDB
Constraints".
column or a too-large numeric value into a numeric column, MySQL sets the
NOT NULL
and
columns are handled as described in
ENUM
SET
or '2000-02-00'). The idea is that it is not the job of the SQL server to validate
is stored in the column instead.
into a column that doesn't take
NULL
statements. For multiple-row
statement specifies no value for a column, MySQL inserts its default value if the
ON DELETE
Section 5.1.7, "Server SQL
NULL
statements or for
INSERT
Section 11.1.7, "Data Type Default
clause. If the definition has no such
DEFAULT
30
CASCADE. Cascading operations may not
InnoDB
Section 14.2.3.4,
Modes".
Section 1.8.6.4,
and
DATE
DATETIME
values, an error occurs for single-
INSERT INTO ... SELECT
Values".
sets shared row-
"InnoDB
"ENUM
and
columns (such
clause,
DEFAULT

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents