473,385 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

AW: mutual declarations produce Error 1005 (errno: 150)

mysql> USE company;
Database changed
mysql>
mysql> DROP TABLE IF EXISTS EMPLOYEE;
--------------
DROP TABLE IF EXISTS EMPLOYEE
--------------

Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> CREATE TABLE EMPLOYEE
-> (
-> FNAME VARCHAR(15) NOT NULL,
-> MINIT CHAR,
-> LNAME VARCHAR(15) NOT NULL,
-> SSN CHAR(9) NOT NULL,
-> BDATE DATE,
-> ADDRESS VARCHAR(30),
-> SEX CHAR,
-> SALARY DECIMAL(10,2),
-> SUPERSSN CHAR(9),
-> DNO INT NOT NULL DEFAULT 1,
-> PRIMARY KEY (SSN),
-> INDEX (SUPERSSN),
-> INDEX (DNO)
-> )TYPE =3D INNODB;
--------------
CREATE TABLE EMPLOYEE
(
FNAME VARCHAR(15) NOT NULL,
MINIT CHAR,
LNAME VARCHAR(15) NOT NULL,
SSN CHAR(9) NOT NULL,
BDATE DATE,
ADDRESS VARCHAR(30),
SEX CHAR,
SALARY DECIMAL(10,2),
SUPERSSN CHAR(9),
DNO INT NOT NULL DEFAULT 1,
PRIMARY KEY (SSN),
INDEX (SUPERSSN),
INDEX (DNO)
)TYPE =3D INNODB
--------------

Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> DESCRIBE EMPLOYEE;
--------------
DESCRIBE EMPLOYEE
--------------

+----------+---------------+-------------------+------+-----+---------+-
------+
| Field | Type | Collation | Null | Key | Default |
Extra |
+----------+---------------+-------------------+------+-----+---------+-
------+
| FNAME | varchar(15) | latin1_swedish_ci | | | |
|
| MINIT | char(1) | latin1_swedish_ci | YES | | NULL |
|
| LNAME | varchar(15) | latin1_swedish_ci | | | |
|
| SSN | varchar(9) | latin1_swedish_ci | | PRI | |
|
| BDATE | date | latin1_swedish_ci | YES | | NULL |
|
| ADDRESS | varchar(30) | latin1_swedish_ci | YES | | NULL |
|
| SEX | char(1) | latin1_swedish_ci | YES | | NULL |
|
| SALARY | decimal(10,2) | binary | YES | | NULL |
|
| SUPERSSN | varchar(9) | latin1_swedish_ci | YES | MUL | NULL |
|
| DNO | int(11) | binary | | MUL | 1 |
|
+----------+---------------+-------------------+------+-----+---------+-
------+
10 rows in set (0.00 sec)

mysql> SHOW INNODB STATUS \G
--------------
SHOW INNODB STATUS
--------------

*************************** 1. row ***************************
Status:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
030814 10:37:13 INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Per second averages calculated from the last 52 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 32, signal count 32
Mutex spin waits 10, rounds 180, OS waits 1
RW-shared spins 60, OS waits 30; RW-excl spins 1, OS waits 1
------------
TRANSACTIONS
------------
Trx id counter 0 5422
Purge done for trx's n:o < 0 5408 undo n:o < 0 0
Total number of lock structs in row lock hash table 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 5415, not started, OS thread id 2072
MySQL thread id 8, query id 1088 localhost 127.0.0.1 root
SHOW INNODB STATUS
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio
I/O thread 1 state: wait Windows aio
I/O thread 2 state: wait Windows aio
I/O thread 3 state: wait Windows aio
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
62 OS file reads, 759 OS file writes, 245 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.04 writes/s, 0.04 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 34679, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 0.87 non-hash searches/s
---
LOG
---
Log sequence number 0 880300
Log flushed up to 0 880300
Last checkpoint at 0 873305
0 pending log writes, 0 pending chkp writes
136 log i/o's done, 0.04 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 13601916; in additional pool allocated 232832
Buffer pool size 512
Free buffers 480
Database pages 31
Modified db pages 22
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 28, created 3, written 584
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
Main thread id 1408, state: sleeping
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D

1 row in set (0.00 sec)

mysql> DROP TABLE IF EXISTS DEPARTMENT;
--------------
DROP TABLE IF EXISTS DEPARTMENT
--------------
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE DEPARTMENT
-> (
-> DNAME VARCHAR(15) NOT NULL,
-> DNUMBER INT NOT NULL,
-> MGRSSN CHAR(9) NOT NULL DEFAULT '888665555',
-> MGRSTARTDATE DATE,
-> PRIMARY KEY (DNUMBER),
-> UNIQUE (DNAME),
-> INDEX (MGRSSN)
-> )TYPE =3D INNODB;
--------------
CREATE TABLE DEPARTMENT
(
DNAME VARCHAR(15) NOT NULL,
DNUMBER INT NOT NULL,
MGRSSN CHAR(9) NOT NULL DEFAULT '888665555',
MGRSTARTDATE DATE,
PRIMARY KEY (DNUMBER),
UNIQUE (DNAME),
INDEX (MGRSSN)
)TYPE =3D INNODB
--------------

Query OK, 0 rows affected (0.00 sec)

mysql> DESCRIBE DEPARTMENT;
--------------
DESCRIBE DEPARTMENT
--------------

+--------------+-------------+-------------------+------+-----+---------
--+-----
--+
| Field | Type | Collation | Null | Key | Default
| Extr
a |
+--------------+-------------+-------------------+------+-----+---------
--+-----
--+
| DNAME | varchar(15) | latin1_swedish_ci | | UNI |
|
|
| DNUMBER | int(11) | binary | | PRI | 0
|
|
| MGRSSN | varchar(9) | latin1_swedish_ci | | MUL |
888665555 |
|
| MGRSTARTDATE | date | latin1_swedish_ci | YES | | NULL
|
|
+--------------+-------------+-------------------+------+-----+---------
--+-----
--+
4 rows in set (0.00 sec)
mysql> SHOW INNODB STATUS \G
--------------
SHOW INNODB STATUS
--------------

*************************** 1. row ***************************
Status:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
030814 10:44:10 INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Per second averages calculated from the last 45 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 37, signal count 37
Mutex spin waits 15, rounds 280, OS waits 1
RW-shared spins 70, OS waits 35; RW-excl spins 1, OS waits 1
------------
TRANSACTIONS
------------
Trx id counter 0 5427
Purge done for trx's n:o < 0 5424 undo n:o < 0 0
Total number of lock structs in row lock hash table 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 5415, not started, OS thread id 2072
MySQL thread id 8, query id 1134 localhost 127.0.0.1 root
SHOW INNODB STATUS
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio
I/O thread 1 state: wait Windows aio
I/O thread 2 state: wait Windows aio
I/O thread 3 state: wait Windows aio
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
62 OS file reads, 833 OS file writes, 271 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 34679, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 0 886171
Log flushed up to 0 886171
Last checkpoint at 0 886171
0 pending log writes, 0 pending chkp writes
145 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 13601916; in additional pool allocated 230528
Buffer pool size 512
Free buffers 480
Database pages 31
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 28, created 3, written 643
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool activity since the last printout
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
Main thread id 1408, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D

1 row in set (0.00 sec)

mysql> ALTER TABLE EMPLOYEE
-> ADD FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN)
-> ON DELETE SET NULL
-> ON UPDATE CASCADE;
--------------
ALTER TABLE EMPLOYEE
ADD FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN)
ON DELETE SET NULL
ON UPDATE CASCADE
--------------

Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> SHOW INNODB STATUS \G
--------------
SHOW INNODB STATUS
--------------

*************************** 1. row ***************************
Status:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
030814 10:45:56 INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Per second averages calculated from the last 45 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 38, signal count 38
Mutex spin waits 15, rounds 280, OS waits 1
RW-shared spins 72, OS waits 36; RW-excl spins 1, OS waits 1
------------
TRANSACTIONS
------------
Trx id counter 0 5442
Purge done for trx's n:o < 0 5439 undo n:o < 0 0
Total number of lock structs in row lock hash table 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 5441, not started, OS thread id 2072
MySQL thread id 8, query id 1147 localhost 127.0.0.1 root
SHOW INNODB STATUS
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio
I/O thread 1 state: wait Windows aio
I/O thread 2 state: wait Windows aio
I/O thread 3 state: wait Windows aio
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
62 OS file reads, 869 OS file writes, 282 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.80 writes/s, 0.24 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 34679, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 2.18 non-hash searches/s
---
LOG
---
Log sequence number 0 894279
Log flushed up to 0 894279
Last checkpoint at 0 894279
0 pending log writes, 0 pending chkp writes
151 log i/o's done, 0.13 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 13601916; in additional pool allocated 231296
Buffer pool size 512
Free buffers 480
Database pages 31
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 28, created 3, written 671
0.00 reads/s, 0.00 creates/s, 0.62 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
Main thread id 1408, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D

1 row in set (0.00 sec)

mysql> ALTER TABLE EMPLOYEE
-> ADD FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER)
-> ON DELETE SET DEFAULT
-> ON UPDATE CASCADE;
--------------
ALTER TABLE EMPLOYEE
ADD FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER)
ON DELETE SET DEFAULT
ON UPDATE CASCADE
--------------
ERROR 1005: Can't create table '.\company\#sql-40c_8.frm' (errno: 150)
mysql> SHOW INNODB STATUS \G
--------------
SHOW INNODB STATUS
--------------

*************************** 1. row ***************************
Status:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
030814 10:48:29 INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Per second averages calculated from the last 30 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 39, signal count 39
Mutex spin waits 15, rounds 280, OS waits 1
RW-shared spins 74, OS waits 37; RW-excl spins 1, OS waits 1
------------
TRANSACTIONS
------------
Trx id counter 0 5447
Purge done for trx's n:o < 0 5439 undo n:o < 0 0
Total number of lock structs in row lock hash table 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 5446, not started, OS thread id 2072
MySQL thread id 8, query id 1164 localhost 127.0.0.1 root
SHOW INNODB STATUS
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio
I/O thread 1 state: wait Windows aio
I/O thread 2 state: wait Windows aio
I/O thread 3 state: wait Windows aio
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
62 OS file reads, 885 OS file writes, 287 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 34679, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 0 899726
Log flushed up to 0 899726
Last checkpoint at 0 899726
0 pending log writes, 0 pending chkp writes
153 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 13601916; in additional pool allocated 233600
Buffer pool size 512
Free buffers 480
Database pages 31
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 28, created 3, written 684
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool activity since the last printout
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
Main thread id 1408, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D

1 row in set (0.00 sec)
mysql> SHOW TABLE STATUS FROM company LIKE "EMPLOYEE" \G
--------------
SHOW TABLE STATUS FROM company LIKE "EMPLOYEE"
--------------

*************************** 1. row ***************************
Name: employee
Type: InnoDB
Row_format: Dynamic
Rows: 0
Avg_row_length: 0
Data_length: 16384
Max_data_length: NULL
Index_length: 32768
Data_free: 0
Auto_increment: NULL
Create_time: NULL
Update_time: NULL
Check_time: NULL
Charset: latin1_swedish_ci
Create_options:
Comment: InnoDB free: 3072 kB; (SUPERSSN) REFER
company/employee(SSN) ON
UPDATE CASCADE
1 row in set (0.00 sec)
mysql> SHOW TABLE STATUS FROM company LIKE "DEPARTMENT" \G
--------------
SHOW TABLE STATUS FROM company LIKE "DEPARTMENT"
--------------

*************************** 1. row ***************************
Name: department
Type: InnoDB
Row_format: Dynamic
Rows: 0
Avg_row_length: 0
Data_length: 16384
Max_data_length: NULL
Index_length: 32768
Data_free: 0
Auto_increment: NULL
Create_time: NULL
Update_time: NULL
Check_time: NULL
Charset: latin1_swedish_ci
Create_options:
Comment: InnoDB free: 3072 kB
1 row in set (0.00 sec)

mysql>
=3D=3D=3D=3D=3D

Hi again,
I have just tried to investigate and record what InnoDB status has
noticed,

According to the MySQL reference manual,
A foreign key constraint is in My Code erroneously coded,

=3D=3D
If MySQL gives the error number 1005 from a CREATE TABLE
statement, and the error message string refers to errno 150, then
the table creation failed because a foreign key constraint was not
correctly formed. Similarly, if an ALTER TABLE fails and it refers
to errno 150, that means a foreign key definition would be incorrectly
formed for the altered table. Starting from version 4.0.13, you can
use SHOW INNODB STATUS to look at a detailed explanation of the
latest InnoDB foreign key error in the server.
=3D=3D=20
According to my general SQL experience it is all correctly=20
ANSI SQL-92 coded.

Please help me,

What else can be done ?

Yours Sincerely

Morten Gulbrandsen


-----Urspr=FCngliche Nachricht-----
Von: Fred van Engen [mailto:fr************@xbn.nl]=20
Gesendet: Mittwoch, 13. August 2003 15:36
An: Morten Gulbrandsen
Cc: 'Victoria Reznichenko'; my***@lists.mysql.com
Betreff: Re: mutual declarations produce Error 1064

Morten,

In your extremely long mail, I think I managed to find your question and
removed all other stuff.

On Wed, Aug 13, 2003 at 03:18:26PM +0200, Morten Gulbrandsen wrote:
mysql>
mysql> # from now on the coding causes trouble
mysql>
mysql> ALTER TABLE EMPLOYEE
-> FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN)
-> ON DELETE SET NULL
-> ON UPDATE CASCADE;
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresp
onds to your MySQL server version for the right syntax to use near
'FOREIGN KEY
(SUPERSSN) REFERENCES EMPLOYEE(SSN)
ON DELETE SET
mysql>


6.5.4 ALTER TABLE Syntax

ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification
....]

alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
| ADD [COLUMN] (create_definition, create_definition,...)
| ADD INDEX [index_name] (index_col_name,...)
| ADD PRIMARY KEY (index_col_name,...)
| ADD UNIQUE [index_name] (index_col_name,...)
| ADD FULLTEXT [index_name] (index_col_name,...)
| ADD [CONSTRAINT symbol] FOREIGN KEY [index_name]
(index_col_name,...)
[reference_definition]
| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
| CHANGE [COLUMN] old_col_name create_definition
[FIRST | AFTER column_name]
| MODIFY [COLUMN] create_definition [FIRST | AFTER column_name]
| DROP [COLUMN] col_name
| DROP PRIMARY KEY
| DROP INDEX index_name
| DISABLE KEYS
| ENABLE KEYS
| RENAME [TO] new_tbl_name
| ORDER BY col
| table_options

So what it clearly tells you, is to use this (note the 'ADD'):

mysql> ALTER TABLE EMPLOYEE
-> ADD FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN)
-> ON DELETE SET NULL
-> ON UPDATE CASCADE;
Regards,

Fred.

--=20
Fred van Engen XB Networks B.V.
email: fr************@xbn.nl Televisieweg 2
tel: +31 36 5462400 1322 AC Almere
fax: +31 36 5462424 The Netherlands

--=20
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: =
http://lists.mysql.com/my***************@owi-aachen.de
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 2708

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
0
by: Morten Gulbrandsen | last post by:
USE company; # SHOW INNODB STATUS; DROP TABLE IF EXISTS DEPARTMENT; CREATE TABLE DEPARTMENT ( DNAME VARCHAR(15) NOT NULL, DNUMBER INT NOT NULL,
0
by: CoOL! . | last post by:
Hello, I found the key to solve this problem in: http://darkstar.ist.utl.pt/mysql/doc/en/InnoDB_foreign_key_constraints.html You'll probably need an INDEX for that new foreign key you are...
0
by: Morten Gulbrandsen | last post by:
Hello programmers, I think something is wrong with my administration, Basically I get these messages, ERROR 1005 at line 9: Can't create table '.\company\department.frm' (errno: 150) ERROR...
0
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
11
by: frr | last post by:
Hi, After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error: >>> import themes Traceback (most recent call last): File "<interactive input>", line 1, in ? File "themes.py", line...
2
by: jith87 | last post by:
This is MySql lang...Link nt able to poen so i ve posted here.. What is error 1005 Can't create table (errno:150)....... There is a field X in a table Y. This X field has to be accessed by another...
6
by: daveftl | last post by:
Good day to all...i always have this error after making an ALTER command ... #1005 - Can't create table '.\_ftl\#sql-918_f.frm' (errno: 150) whats the cause of this error...thanks in advance..
1
by: sprooj | last post by:
hi,I'm trying to add a foreign key constraint to an attribute using MySQL , but an error keeps on appearing : ERROR 1005 (HY000): Can't create table '.\is224\#sql- 110c_1.frm' (errno:150) Can...
9
by: AmiMitra | last post by:
i am using mysql 5.1. i have one table named as resv_record. the format is create table resv_record ( book enum('h','c','r','f','t') , resv_id int(8) auto_increment not null , user_id varchar(12)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.