How Mysql Deals With Constraints - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

shell>
replace " --" " #" < text-file-with-funny-comments.sql \
| mysql db_name
That is safer than executing the script in the usual way:
shell>
mysql db_name < text-file-with-funny-comments.sql
You can also edit the script file "in place" to change the "--" comments to "#" comments:
shell>
replace " --" " #" -- text-file-with-funny-comments.sql
Change them back with this command:
shell>
replace " #" " --" -- text-file-with-funny-comments.sql
See
Section 4.8.2,

1.8.6. How MySQL Deals with Constraints

MySQL enables you to work both with transactional tables that permit rollback and with
nontransactional tables that do not. Because of this, constraint handling is a bit different in MySQL
than in other DBMSs. We must handle the case when you have inserted or updated a lot of rows in a
nontransactional table for which changes cannot be rolled back when an error occurs.
The basic philosophy is that MySQL Server tries to produce an error for anything that it can detect
while parsing a statement to be executed, and tries to recover from any errors that occur while
executing the statement. We do this in most cases, but not yet for all.
The options MySQL has when an error occurs are to stop the statement in the middle or to recover as
well as possible from the problem and continue. By default, the server follows the latter course. This
means, for example, that the server may coerce illegal values to the closest legal values.
Beginning with MySQL 5.0.2, several SQL mode options are available to provide greater control over
handling of bad data values and whether to continue statement execution or abort when errors occur.
Using these options, you can configure MySQL Server to act in a more traditional fashion that is like
other DBMSs that reject improper input. The SQL mode can be set globally at server startup to affect
all clients. Individual clients can set the SQL mode at runtime, which enables each client to select the
behavior most appropriate for its requirements. See
The following sections describe how MySQL Server handles different types of constraints.
1.8.6.1.
PRIMARY KEY
Normally, errors occurs for data-change statements (such as
primary-key, unique-key, or foreign-key constraints. If you are using a transactional storage engine
such as InnoDB, MySQL automatically rolls back the statement. If you are using a nontransactional
storage engine, MySQL stops processing the statement at the row for which the error occurred and
leaves any remaining rows unprocessed.
MySQL supports an
primary-key or unique-key violations and continues processing with the next row. See the section for
the statement that you are using
and so forth).
You can get information about the number of rows actually inserted or updated with the
mysql_info()
Section 20.6.6.35,
Currently, only
Constraints".
How MySQL Deals with Constraints
"replace
— A String-Replacement
and
Index Constraints
UNIQUE
keyword for INSERT, UPDATE, and so forth. If you use it, MySQL ignores
IGNORE
(Section 13.2.5,
C API function. You can also use the
"mysql_info()", and
tables support foreign keys. See
InnoDB
Utility".
Section 5.1.7, "Server SQL
INSERT
"INSERT
Syntax",
SHOW WARNINGS
Section 13.7.5.37,
"SHOW WARNINGS
Section 14.2.3.4,
28
Modes".
or UPDATE) that would violate
Section 13.2.10,
"UPDATE
statement. See
Syntax".
"InnoDB
and
FOREIGN KEY
Syntax",

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 5.0 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Mysql 5.0

Table of Contents