[标准SQL的外键约束条件] 1): 子表引用父表的主键 drop table if exists child,parent; create table if not exists parent( id int not null auto_increment primary key, v int ); create table if not exists child( id int not null auto_increment primary key, parent_id int not nu
select a.constraint_name, a.table_name, b.constraint_name from user_constraints a, user_constraints b where a.constraint_type = 'R' and b.constraint_type = 'P' and a.r_constraint_name = b.constraint_name -- P 代表主键, R 代表外键 查询某一张表的约束: select constrai