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. Win8.1 MSDN各版本下载(64位/32位,简体中文,繁体中文,英文),X86&X64,EN,CHS,CHT

    英文64位ed2k://|file|en_windows_8_1_x64_dvd_2707217.iso|3899295744|8E604054013D21209B851E41DC19F6F5|/ 英 ...

  2. 在C51中如何实现软复位?

    可以定义一个指向复位向量(0x0000)的函数指针,然后在C程序中需要软复位的地方调用该函数: ((void (code *) (void)) 0x0000) (); 例如,以下程序不断地复位: vo ...

  3. OpenSceneGraph是一个开源的三维引擎

    http://www.osgchina.org/OpenSceneGraph是一个开源的三维引擎,被广泛的应用在可视化仿真.游戏.虚拟现实.科学计算.三维重建.地理信息.太空探索.石油矿产等领域.OS ...

  4. EXTJS 4.2 实现 gridpanel 鼠标悬停单元格以提示信息的方式显示单元格内容。

    由于gridpanel的单元格里的文字太多时候,都由省略号代替,就想实现如题的功能,经过反复实验,终于搞定了!直接上代码: me.on('itemmouseenter', function (view ...

  5. windows 守护进程

    use Win32::Process::Info; while (1==1){ use Sys::Hostname; use HTTP::Date qw(time2iso str2time time2 ...

  6. pl/sql执行动态sql

    SQL> declare             msql varchar2(200);    begin    loop    msql := 'select * from bfw_test' ...

  7. Hdu3487-Play with Chain(伸展树分裂合并)

    Problem Description YaoYao is fond of playing his chains. He has a chain containing n diamonds on it ...

  8. 杭州网赛 two rabbits (hdu 4745)

    算法很简单,问题是,怎么证明,答案是回文序列. 设a,b走的序列按顺时针是: a1 , a2 , a3 , ... , ak b1 , b2 , b3 , ... , bk 考虑端点的2种情况: 1. ...

  9. softlayer

  10. FTP Client

    1: /// <summary> 2: /// FTP 管理类 3: /// </summary> 4: public class FTPManage 5: { 6: priv ...