Oracle 5.0 Reference Manual page 46

Table of Contents

Advertisement

using an
AUTO_INCREMENT
or the
mysql_insert_id()
Section 20.6.6.37,
You can generally code around the need for row-level locking. Some situations really do need it, and
tables support row-level locking. Otherwise, with
InnoDB
in the table and do something like the following:
UPDATE
tbl_name
MySQL returns
original row. You can think of this as though MySQL Server changed the preceding statement to:
UPDATE
tbl_name
1.8.5.4. Foreign Keys
The
InnoDB
DELETE, and
For storage engines other than InnoDB, MySQL Server parses the
statements, but does not use or store it. In the future, the implementation will be extended
TABLE
to store this information in the table specification file so that it may be retrieved by
ODBC. At a later stage, foreign key constraints will be implemented for
Foreign key enforcement offers several benefits to database developers:
• Assuming proper design of the relationships, foreign key constraints make it more difficult for a
programmer to introduce an inconsistency into the database.
• Centralized checking of constraints by the database server makes it unnecessary to perform these
checks on the application side. This eliminates the possibility that different applications may not all
check the constraints in the same way.
• Using cascading updates and deletes can simplify the application code.
• Properly designed foreign key rules aid in documenting relationships between tables.
Do keep in mind that these benefits come at the cost of additional overhead for the database server to
perform the necessary checks. Additional checking by the server affects performance, which for some
applications may be sufficiently undesirable as to be avoided if possible. (Some major commercial
applications have coded the foreign key logic at the application level for this reason.)
MySQL gives database developers the choice of which approach to use. If you don't need foreign
keys and want to avoid the overhead associated with enforcing referential integrity, you can choose
another storage engine instead, such as MyISAM. (For example, the
very fast performance for applications that perform only
the table has no holes in the middle and the inserts can be performed concurrently with retrievals. See
Section 8.7.3, "Concurrent
If you choose not to take advantage of referential integrity checks, keep the following considerations in
mind:
• In the absence of server-side foreign key relationship checking, the application itself must handle
relationship issues. For example, it must take care to insert rows into tables in the proper order, and
to avoid creating orphaned child records. It must also be able to recover from errors that occur in the
middle of multiple-record insert operations.
• If
ON DELETE
similar effect as of MySQL Server 4.0 by using multiple-table
many tables with a single statement. See
MySQL Differences from Standard SQL
column and either the
C API function. See
"mysql_insert_id()".
SET row_flag=1 WHERE id=ID;
for the number of affected rows if the row was found and
1
SET row_flag=1 WHERE id=ID AND row_flag <> 1;
storage engine supports checking of foreign key constraints, including CASCADE,
UPDATE. See
Section 14.2.3.4,
ON
Inserts".)
is the only referential integrity capability an application needs, you can achieve a
LAST_INSERT_ID()
Section 12.13, "Information
MyISAM
"InnoDB
and
FOREIGN KEY
and
INSERT
DELETE
Section 13.2.2,
"DELETE
26
[961]
SQL function
Functions", and
tables, you can use a flag column
wasn't
row_flag
Constraints".
syntax in
FOREIGN KEY
mysqldump
tables as well.
MyISAM
storage engine offers
MyISAM
operations. In this case,
SELECT
statements to delete rows from
Syntax".
in the
1
ON
CREATE
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents