Oracle 5.0 Reference Manual page 1277

Table of Contents

Advertisement

permits a foreign key to reference any index column or group of columns. However, in
InnoDB
the referenced table, there must be an index where the referenced columns are listed as the first
columns in the same order.
does not currently support foreign keys for tables with user-defined partitioning. This means
InnoDB
that no user-partitioned
foreign keys.
allows a foreign key constraint to reference a non-unique key. This is an
InnoDB
to standard SQL.
Referential Actions
Referential actions for foreign keys of
• While
SET DEFAULT
and
TABLE
• If there are several rows in the parent table that have the same referenced key value,
in foreign key checks as if the other parent rows with the same key value do not exist. For example,
if you have defined a
does not permit the deletion of any of those parent rows.
InnoDB
performs cascading operations through a depth-first algorithm, based on records in the
InnoDB
indexes corresponding to the foreign key constraints.
• If
ON UPDATE CASCADE
previously updated during the cascade, it acts like RESTRICT. This means that you cannot use self-
referential
loops resulting from cascaded updates. A self-referential
is possible, as is a self-referential
more than 15 levels deep.
• Like MySQL in general, in an SQL statement that inserts, deletes, or updates many rows,
checks
UNIQUE
sets shared row-level locks on child or parent records it has to look at.
InnoDB
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. Until
constraint checking, some things will be impossible, such as deleting a record that refers to itself
using a foreign key.
Foreign Key Usage and Error Information
You can obtain general information about foreign keys and their usage from querying the
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
tables can be found in the
the
INFORMATION_SCHEMA
In addition to
150 in the MySQL Server), you can obtain a detailed explanation of the most recent
key error by checking the output of
14.2.3.5.
and MySQL Replication
InnoDB
MySQL replication works for
replication in a way where the storage engine on the slave is not the same as the original storage
engine on the master. For example, you can replicate modifications to an
to a
MyISAM
To set up a new slave for a master, you have to make a copy of the
log files, as well as the
Creating and Using
table may contain foreign key references or columns referenced by
InnoDB
is allowed by the MySQL Server, it is rejected as invalid by InnoDB.
statements using this clause are not allowed for InnoDB tables.
ALTER TABLE
type constraint, and there is a child row with several parent rows,
RESTRICT
or
ON UPDATE SET NULL
ON UPDATE CASCADE
and
FOREIGN KEY
INNODB_SYS_FOREIGN
database. See also
ERRORS, in the event of a foreign key error involving
SHOW
InnoDB
table on the slave.
files of the
.frm
Tables
InnoDB
tables are subject to the following conditions:
InnoDB
recurses to update the same table it has
or
ON UPDATE SET NULL
CASCADE. Cascading operations may not be nested
ON DELETE
constraints row-by-row. When performing foreign key checks,
table, and more information more specific to
and
INNODB_SYS_FOREIGN_COLS
Section 13.1.10.2, "Using
SHOW ENGINE INNODB
tables as it does for
tables, and move the copies to the slave. If the
InnoDB
1257
operations. This is to prevent infinite
NULL, on the other hand,
ON DELETE SET
implements deferred
InnoDB
FOREIGN KEY
InnoDB
STATUS.
tables. It is also possible to use
MyISAM
InnoDB
tablespace and the
InnoDB
extension
InnoDB
CREATE
acts
InnoDB
InnoDB
checks
InnoDB
InnoDB
tables, also in
Constraints".
tables (usually Error
foreign
InnoDB
table on the master

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents