Oracle 5.0 Reference Manual page 47

Table of Contents

Advertisement

• A workaround for the lack of
application when you delete records from a table that has a foreign key. In practice, this is often as
quick as using foreign keys and is more portable.
Be aware that the use of foreign keys can sometimes lead to problems:
• Foreign key support addresses many referential integrity issues, but it is still necessary to design key
relationships carefully to avoid circular rules or incorrect combinations of cascading deletes.
• It is not uncommon for a DBA to create a topology of relationships that makes it difficult to
restore individual tables from a backup. (MySQL alleviates this difficulty by enabling you to
temporarily disable foreign key checks when reloading a table that depends on other tables. See
Section 14.2.3.4,
generates dump files that take advantage of this capability automatically when they are reloaded.)
Foreign keys in SQL are used to check and enforce referential integrity, not to join tables. If you want
to get results from multiple tables from a
them:
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
See
Section 13.2.8.2,
The
FOREIGN KEY
automatic
WHERE
1.8.5.5. '--' as the Start of a Comment
Standard SQL uses the C syntax
supports this syntax as well. MySQL also support extensions to this syntax that enable MySQL-specific
SQL to be embedded in the comment, as described in
Standard SQL uses "--" as a start-comment sequence. MySQL Server uses "#" as the start comment
character. MySQL Server 3.23.3 and up also supports a variant of the "--" comment style. That is,
the "--" start-comment sequence must be followed by a space (or by a control character such as a
newline). The space is required to prevent problems with automatically generated SQL queries that use
constructs such as the following, where we automatically insert the value of the payment for payment:
UPDATE account SET credit=credit-payment
Consider about what happens if
UPDATE account SET credit=credit--1
credit--1
the expression is discarded. The result is a statement that has a completely different meaning than
intended:
UPDATE account SET credit=credit
The statement produces no change in value at all. This illustrates that permitting comments to start with
"--" can have serious consequences.
Using our implementation requires a space following the "--" for it to be recognized as a start-comment
sequence in MySQL Server 3.23.3 and newer. Therefore,
Another safe feature is that the
The following information is relevant only if you are running a MySQL version earlier than 3.23.3:
If you have an SQL script in a text file that contains "--" comments, you should use the
as follows to convert the comments to use "#" characters before executing the script:
MySQL Differences from Standard SQL
ON DELETE
"InnoDB
and
FOREIGN KEY
"JOIN
Syntax", and
syntax without
ON DELETE ...
clauses.
/* this is a comment */
payment
is a legal expression in SQL, but "--" is interpreted as the start of a comment, part of
mysql
is to add the appropriate
Constraints". As of MySQL 4.1.1,
statement, you do this by performing a join between
SELECT
Section 3.6.6, "Using Foreign
is often used by ODBC applications to produce
Section 9.6, "Comment
has a negative value such as -1:
credit--1
command-line client ignores lines that start with "--".
27
statements to your
DELETE
mysqldump
Keys".
for comments, and MySQL Server
Syntax".
is safe to use.
replace
utility

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

This manual is also suitable for:

Mysql 5.0

Table of Contents