information_schema.referential_constraints 学习
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 学习的更多相关文章
- information_schema.profiling学习
information_schema.profiling可以用来分析每一条SQL在它执行的各个阶段的用时,注意这个表是session 级的,也就是说如果session1 开启了它:session2没有 ...
- information_schema.optimizer_trace学习
information_schema.optimizer_trace 用于追踪优化器的优化过程:通常来说这张表中是没有数据的,要想开户追踪要把 @@session.optimizer_trace='e ...
- information_schema.triggers 学习
mysql实例中的每一个trigger 对应到information_schema.triggers 中有一行 1.information_schema.triggers 表的常用列: 1.trigg ...
- information_schema.routines 学习
information_schema.routines 用户查看mysql中的routine信息 1.information_schema.routines 表中的常用列: 1.
- information_schema.key_column_usage 学习
information_schema.key_column_usage 表可以查看索引列上的约束: 1.information_schema.key_column_usage 的常用列: 1.cons ...
- information_schema.events 学习
information_schema.events 表保存了整个mysql实例中的event 信息 1.常用列: 1.event_catalog :永远是def 2.event_schema :eve ...
- information_schema.engines学习
当前mysql实例的存储引擎信息可以从information_schema.engines 中查询到 例子: mysql> select * from information_schema.en ...
- information_schema.column_privileges 学习
mysql 的授权是分层次的 实例级 | 库级 | 表级 | 列级 而这些授权信息被保存在了mysql.user | mysql.db | mysql.tables_priv | mysql.colu ...
- information_schema.columns 学习
每一个表中的每一列都会在information_schema.columns表中对应一行 1.informaiton_schema.columns 常用列: 1.table_catalog :不管是t ...
随机推荐
- HTTP 协议简介
HTTP 协议简介 博客分类: acl开发--HTTP协议篇 网络协议http协议 一.TCP/IP 协议介绍 在介绍 HTTP 协议之前,先简单说一下TCP/IP协议的相关内容.TCP/IP协议是 ...
- LeetCode_Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- (转载)解决WPF动画属性锁死问题
此文来自: 马开东博客 转载请注明出处 网址:http://www.makaidong.com 一般锁死问题都是出在后台代码写的动画中,以下为转载的解决方案! 方法一:将动画的 FillBehavio ...
- Android setTextColor无效_安卓setTextColor()的参数设置方式
通过代码setTextColor时.如果color是一个资源文件 会set失败 没有效果 遇到这样的情况有两种解决办法.亲测过.两种都是有效的 一.注解方式 通过在方法上面添加注解解决问题 代码如下 ...
- 深入浅出CChart 每日一课——第十八课 女神的套娃,玩转对话框
前面笨笨已经给大家展示了CChart编程的N个例子.这些例子中,我们的CChart图像都是绘制在程序的主窗口中的. 在很多情况下,我们面对的情形不是这样的.这节课笨笨就给大家介绍一下怎样在对话框中用C ...
- (\S)? 匹配0个或者一个前导字符
---------------------------------------------- "1" 模式: \"(?<id>(\S+)?)\" ? ...
- log4net logfornet 配置和用法
较好的参考地址: http://in3040.blog.163.com/blog/static/116702443201091354028744/ http://dev.tot.name/dotnet ...
- [转载]用可变参数宏(variadic macros)传递可变参数表
注意:_VA_ARGS__ 从VS2005才开始支持 在 GNU C 中,宏可以接受可变数目的参数,就象函数一样,例如: #define pr_debug(fmt,arg...) printk(KER ...
- 理解mcelog如何工作
前言 本文,带你了解几个问题? 本文重点,主要看案例2,带你很好的理解mcelog如何工作的? mcelog的干什么的? mcelog 是 x86 的 Linux 系统上用来 检查硬件错误,特别是内存 ...
- 打造自己个性的notepad ++
对coder来说,notepad ++ 是一个很不错的文本编辑器.平时用来看看代码.xml文件,都比系统自带的记事本舒服得多.不过,对于像我这种每天用notepad ++写代码的人,一个原装的note ...