【发布时间】:2011-02-23 18:02:00
【问题描述】:
我正在学习 SQL,但困扰我的是,我似乎无法在表上找到所有约束。我用
创建了表格create table t2
(a integer not null primary key,
b integer not null, constraint c1 check(b>0),
constraint fk1 foreign key(a) references t1(a));
并添加了一个约束
alter table t2
add constraint c2 check (b<20);
然后我尝试查看所有(四个)约束
show table status
from tenn #-->the name of my database
like 't2';
然后
show create table t2;
然后
select *
from information_schema.key_column_usage
where table_name='t2';
最后
select *
from information_schema.table_constraints
where table_name='t2';
但这些都没有显示所有四个约束。谁能告诉我如何查看所有这些?
非常感谢!
【问题讨论】:
-
您能否指定您运行的查询的结果是什么? * P.S 听说mysql不支持检查约束。
-
虽然你尝试过 CONSTRAINT_COLUMN_USAGE?
-
您可以尝试直接查询系统表,而不是Information Schema视图
标签: mysql