执行我的代码不会导致错误,也没有在此服务器上创建预期的密钥:
create table table1 (
id int not null auto_increment primary key,
name varchar(10) not null default ''
) engine=innodb;
create table table2 (
id int not null auto_increment primary key,
idTable1 int null references table1(id) on delete cascade
) engine=innodb;
Run Code Online (Sandbox Code Playgroud)
我已经看到一些声明限制为:
columnName int not null, foreign key (columnName) references table1(id) on delete cascade
Run Code Online (Sandbox Code Playgroud)
但我想我之前已经使用过以前的语法,它可以在不同的服务器上运行.我只是不记得了.
你以前见过这个吗?假设我的语法可以在MSSQL上运行,我错了吗?如果是这样,为什么这不会导致错误抛出?
编辑.:
SET storage_engine=INNODB;在运行查询之前,InnoDB已启用并设置为默认值.
使用第二个语法示例添加的键工作.添加了alter table的键也可用.
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |