information_schema.referential_constraints 表用于查看外键约束

1、information_schema.referential_constraints表的常用列:

  1、constraint_schema                :约束(外键)所在的库名

  2、constraint_name                  :约束名(外键名)

  3、unique_constraint_schema            :被引用约束所在库名

  4、unique_constraint_name              :被引用约束名

2、例子:

  1、定义一对有外键约束的表:

create table teacher(
id int not null auto_increment,
name varchar(4),
constraint pk__teacher primary key(id),
constraint ix__teacher__name unique index (name))
engine=innodb default char set utf8; create table student(
id int not null auto_increment,
name varchar(4),
teacher_id int not null,
teacher_name varchar(4),
constraint pk__student primary key(id),
constraint fk__student__id foreign key (teacher_id ) references teacher(id),
constraint fk__student__teacher_name foreign key (teacher_name) references teacher(name) on delete no action on update cascade)
engine=innodb default char set utf8;

  2、查看外键约束

select * from information_schema.referential_constraints \G
*************************** 1. row ***************************
CONSTRAINT_CATALOG: def
CONSTRAINT_SCHEMA: tempdb
CONSTRAINT_NAME: fk__student__id
UNIQUE_CONSTRAINT_CATALOG: def
UNIQUE_CONSTRAINT_SCHEMA: tempdb
UNIQUE_CONSTRAINT_NAME: PRIMARY
MATCH_OPTION: NONE
UPDATE_RULE: RESTRICT
DELETE_RULE: RESTRICT
TABLE_NAME: student
REFERENCED_TABLE_NAME: teacher
*************************** 2. row ***************************
CONSTRAINT_CATALOG: def
CONSTRAINT_SCHEMA: tempdb
CONSTRAINT_NAME: fk__student__teacher_name
UNIQUE_CONSTRAINT_CATALOG: def
UNIQUE_CONSTRAINT_SCHEMA: tempdb
UNIQUE_CONSTRAINT_NAME: ix__teacher__name
MATCH_OPTION: NONE
UPDATE_RULE: CASCADE
DELETE_RULE: NO ACTION
TABLE_NAME: student
REFERENCED_TABLE_NAME: teacher

information_schema.referential_constraints 学习的更多相关文章

  1. information_schema.profiling学习

    information_schema.profiling可以用来分析每一条SQL在它执行的各个阶段的用时,注意这个表是session 级的,也就是说如果session1 开启了它:session2没有 ...

  2. information_schema.optimizer_trace学习

    information_schema.optimizer_trace 用于追踪优化器的优化过程:通常来说这张表中是没有数据的,要想开户追踪要把 @@session.optimizer_trace='e ...

  3. information_schema.triggers 学习

    mysql实例中的每一个trigger 对应到information_schema.triggers 中有一行 1.information_schema.triggers 表的常用列: 1.trigg ...

  4. information_schema.routines 学习

    information_schema.routines 用户查看mysql中的routine信息 1.information_schema.routines 表中的常用列: 1.

  5. information_schema.key_column_usage 学习

    information_schema.key_column_usage 表可以查看索引列上的约束: 1.information_schema.key_column_usage 的常用列: 1.cons ...

  6. information_schema.events 学习

    information_schema.events 表保存了整个mysql实例中的event 信息 1.常用列: 1.event_catalog :永远是def 2.event_schema :eve ...

  7. information_schema.engines学习

    当前mysql实例的存储引擎信息可以从information_schema.engines 中查询到 例子: mysql> select * from information_schema.en ...

  8. information_schema.column_privileges 学习

    mysql 的授权是分层次的 实例级 | 库级 | 表级 | 列级 而这些授权信息被保存在了mysql.user | mysql.db | mysql.tables_priv | mysql.colu ...

  9. information_schema.columns 学习

    每一个表中的每一列都会在information_schema.columns表中对应一行 1.informaiton_schema.columns 常用列: 1.table_catalog :不管是t ...

随机推荐

  1. Android DrawerLayout 点击事情穿透

    今天使用DrawerLayout做网易4.4版本侧边栏发现点击DrawerLayout空白部分,下面部分content会获得点击事件.解决方法是在<!-- The navigation draw ...

  2. 对163k地方门户网站系统QQ互联功能修改

    163k地方门户网站QQ互联申请时遇到的问题: "禁止开发商强制用户重新注册或绑定其他帐号" 原因是用户登录完QQ还需要注册帐号或者绑定原有帐号 163k地方门户网站的QQ互联登录 ...

  3. keil c51编译器的一些使用心得

    现在的存储器已经不像七八年前那样昂贵了,但是ram相对于rom和eeprom的价格还是不可同样看待的,所以程序中节省内存在现在看来还是非常关键的.原因有以下几点: 1.ram的存取速度相对于eepro ...

  4. 【转帖】.Net中C#的DllImport的用法

    在 C# 中通过 P/Invoke 调用Win32 DLL http://msdn.microsoft.com/zh-cn/library/aa686045.aspx   大家在实际工作学习C#的时候 ...

  5. 读论文系列:Nearest Keyword Search in XML Documents中使用的数据结构(CT、ECT)

    Reference: [1]Y. Tao, S. Papadopoulos, C. Sheng, K. Stefanidis. Nearest Keyword Search in XML Docume ...

  6. c++ 02

    一.堆内存的动态分配与释放 malloc/calloc/realloc/free new/delete:详见memory.cpp 1.通过new运算符分配单个变量 数据类型* 指针变量 = new 数 ...

  7. Visual Assist X在Windows 8.1下出现中文乱码的解决方法

    这主要是输入法造成的,我的输入法中有US.中文.搜狗输入法三个输入法:通过搜狗输入法管理器把“中文”去掉,或者通过语言首选项把“中文”去掉就不会在出现乱码. 这个办法的思路来自于http://www. ...

  8. hdu 4585 Shaolin_set用法

    题目链接 题意:有n个人想成为少林,但是成为少林必须跟少林的大师大一场,当然要选择战斗力很近的,有两大师战斗力跟那人相近程度一样就选战斗力小的那个,按输入顺序,先输入的人先成为少林大师,后面输入的人, ...

  9. 【POJ2196】Specialized Four-Digit Numbers(暴力打表)

    一道水题,只要会复制粘贴就好! #include <iostream> #include <cstring> #include <cstdlib> #include ...

  10. 后台数据导出为Excel

    数据导出的方法如下: 一.下载office的类库:microsoft.office.interop.excel.zip 根据电脑安装的office版本选择引入相应的类库,office2007选择12. ...