|
Тема
|
Iadove s mySQL
|
|
Автор | SQL user (Нерегистриран) |
Публикувано | 02.11.02 22:43 |
|
Instalirah si mysql za windows i reshih da izprobvam Foreign key. Napisah slednite tri reda i ustanovih che tva chudo neshto ne raboti kakto triabva.
Create table t1 (ime char(5) primary key)
create table t2 (ime char(5) references t1)
insert into t2 values('ddddd')
I inserta mina kato pich a foreign key izobshto ne sraboti. Niakoi ima li ideia ot kakvo moje da e tova
| |
|
ko pishe ?
7.5.4.2 Foreign Key Constraints
Starting from version 3.23.43b InnoDB features foreign key constraints. InnoDB is the first MySQL table type which allows you to define foreign key constraints to guard the integrity of your data.
The syntax of a foreign key constraint definition in InnoDB:
[CONSTRAINT symbol] FOREIGN KEY (index_col_name, ...)
REFERENCES table_name (index_col_name, ...)
[ON DELETE CASCADE | ON DELETE SET NULL]
Both tables have to be InnoDB type and there must be an index where the foreign key and the referenced key are listed as the first columns. InnoDB does not auto-create indexes on foreign keys or referenced keys: you have to create them explicitly.
| |
|
|
|
|