MySQL 主键和外键
之前对多表查询没重视,现在根据自己的理解重新分析总结一下
主键和主键约束
主键和外键的存在都是为了保证数据的完整性;
在我的理解中,主键和外键相对,是语义上的;主键约束和外键约束相对,即语法上的
- 主键: 挑选出来,用来唯一标识某一行的字段;数值要求非空唯一
- 主键分为自然主键和代理主键:自然主键是指,该字段除了表示该行唯一之外,存储的数据还有其他的作用,比如身份证(非空唯一);代理主键只起到标识唯一的作用,一般自增生成或者UUID生成,没有其他特定含义;
- 另外,主键可以是几列一起形成联合主键,比如,学生的学号和课程编号一起成为主键,用来标识成绩相关的数据
- 主键约束: 数据库自动对主键进行约束,即唯一非空
添加主键约束的方法为
添加主键约束的几种方式
1.在创建表时创建主键,在字段后面加上 primary key.
create table tablename(
id int primary key,
.......
)
- 1
- 2
- 3
- 4
2.在创建表时创建主键,在表创建的最后来指定主键
create table tablename(
id int,
.......,
primary key(id)
)
- 1
- 2
- 3
- 4
- 5
3.删除主键:以为一个表的主键只有一个,所以只要指定表名就可以删除主键了
alter table 表名 drop primary key;
- 1
4.主键自动增长:一般主键是自增长的字段,不需要指定。
实现添加自增长语句,主键字段后加auto_increment(只适用MySQL)
外键和外键约束
- 外键: 使两张表形成关联的字段,有外键字段的被称为从表,与此对应的被称为主表;
- 外键约束: mysql添加外键约束后,如果主表中的行与从表的数据产生关联,name就不能删除
声明外键约束的方法
alter table 从表 add constraint 外键名称 foreign key (从表外键字段名) references 主表 (主表的主键);
- 1
[外键名称] 用于删除外键约束的,一般建议“_fk”结尾
需要注意的是,两个字段名都需要加括号
删除外键的方法
alter table 从表 drop foreign key 外键名称
- 1
如果不准备删除,可以不给外键命名,可以使用下面这种简单的方式
alter table 从表名 add foreign key (从表外键字段名) references 主表名 (主表的主键);
- 1
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e44c3c0e64.css" rel="stylesheet">
</div>
</article>
<div class="comment-edit-box d-flex">
<a id="commentsedit"></a>
<div class="user-img">
<a href="javascript:void(0);" target="_blank">
<img class="show_loginbox" src="//g.csdnimg.cn/static/user-img/anonymous-User-img.png">
</a>
</div>
<form id="commentform">
<input type="hidden" id="comment_replyId">
<textarea class="comment-content" name="comment_content" id="comment_content" placeholder="想对作者说点什么"></textarea>
<div class="opt-box"> <!-- d-flex -->
<div id="ubbtools" class="add_code">
<a href="#insertcode" code="code" target="_self"><i class="icon iconfont icon-daima"></i></a>
</div>
<input type="hidden" id="comment_replyId" name="comment_replyId">
<input type="hidden" id="article_id" name="article_id" value="79525513">
<input type="hidden" id="comment_userId" name="comment_userId" value="">
<input type="hidden" id="commentId" name="commentId" value="">
<div style="display: none;" class="csdn-tracking-statistics tracking-click" data-report-click="{"mod":"popu_384","dest":""}"><a href="#" target="_blank" class="comment_area_btn">发表评论</a></div>
<div class="dropdown" id="myDrap">
<a class="dropdown-face d-flex align-items-center" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<div class="txt-selected text-truncate">添加代码片</div>
<svg class="icon d-block" aria-hidden="true">
<use xlink:href="#csdnc-triangledown"></use>
</svg>
</a>
<ul class="dropdown-menu" id="commentCode" aria-labelledby="drop4">
<li><a data-code="html">HTML/XML</a></li>
<li><a data-code="objc">objective-c</a></li>
<li><a data-code="ruby">Ruby</a></li>
<li><a data-code="php">PHP</a></li>
<li><a data-code="csharp">C</a></li>
<li><a data-code="cpp">C++</a></li>
<li><a data-code="javascript">JavaScript</a></li>
<li><a data-code="python">Python</a></li>
<li><a data-code="java">Java</a></li>
<li><a data-code="css">CSS</a></li>
<li><a data-code="sql">SQL</a></li>
<li><a data-code="plain">其它</a></li>
</ul>
</div>
<div class="right-box">
<span id="tip_comment" class="tip">还能输入<em>1000</em>个字符</span>
<input type="button" class="btn btn-sm btn-cancel d-none" value="取消回复">
<input type="submit" class="btn btn-sm btn-red btn-comment" value="发表评论">
</div>
</div>
</form>
</div>
<div class="comment-list-container">
<a id="comments"></a>
<div class="comment-list-box">
</div>
<div id="commentPage" class="pagination-box d-none"></div>
</div>
mysql 添加主键和外键【深度解析】
08-16 阅读数 3261
1,主外键的定义主关键字(primarykey):是表中的一个或多个字段,它的值用于唯一地标识表中的某一条记录。 外关键字(foreignkey): 是用于建立或加强两个表数据之间的链接的一列或多列。... 博文 来自: relaxyu的博客
mysql主键和外键
07-23 阅读数 897
什么是主键?作查询字段的适合做索引,加快查找速度一个表中只能有一个primarykey字段对应的字段不容许重复,且不容许赋NULL值如果有多个字段都为PRIMARYKEY,称为复合主键,必须一起创建。... 博文 来自: 朱海燕的博客日记
MySQL的主键和外键
07-16 阅读数 656
使用《MySQL必知必会》中的表,向表products插入数据出错:从报错信息看,应当是表的主键和外键的问题,先用showcreatetableproducts查看表products的创建信息:外键关... 博文 来自: yao5hed的专栏
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_59" data-pid="59" data-track-view="{"mod":"kp_popu_59-860","con":",,SQL"}" data-track-click="{"mod":"kp_popu_59-860","con":",,SQL"}" data-report-view="{"mod":"kp_popu_59-860","keyword":"SQL"}" data-report-click="{"mod":"kp_popu_59-860","keyword":"SQL"}"><iframe src="https://kunpeng-sc.csdnimg.cn/#/preview/109?positionId=59&queryWord=SQL" frameborder="0" width="100%" height="75px" scrolling="no"></iframe></div></div>
MySQL的几个概念:主键,外键,索引,唯一索引
12-06 阅读数 4万+
概念:主键(primarykey)能够唯一标识表中某一行的属性或属性组。一个表只能有一个主键,但可以有多个候选索引。主键常常与外键构成参照完整性约束,防止出现数据不一致。主键可以保证记录的唯一和主键域... 博文 来自: duck_arrow的专栏
MySql中主键约束和主表是什么?外键约束是什么?主表和从表又是什么?怎么创建?
07-20 阅读数 2295
想知道主键约束,就需要知道主键是什么。所谓主键,你可以理解为一个能够标识数据唯一的标志,比如我们设定ID,ID是永远都不能重复的,这就是主键。添加了主键之后,就有了主键约束。比如你的主键是登陆名称,这... 博文 来自: yAYang_mo的博客
MYSQL外键(Foreign Key)的使用
08-09 阅读数 1万+
在MySQL3.23.44版本后,InnoDB引擎类型的表支持了外键约束。外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持);2... 博文 来自: likika2012的专栏
MySQL外键(两列做主键)
04-09 阅读数 201
目的:用两列创建主键表一create table ta1(idintnotnull primary keyauto_increment,pidintnotnull,uname varchar(20))... 博文 来自: qq_39062888的博客
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_60" data-pid="60" data-track-view="{"mod":"kp_popu_60-43","con":",,"}" data-track-click="{"mod":"kp_popu_60-43","con":",,"}" data-report-view="{"mod":"kp_popu_60-43","keyword":""}" data-report-click="{"mod":"kp_popu_60-43","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702738_113" id="QIHOO__WEB__SO__1565322702738_113" style="display:block;margin:0;padding:0;border:none;width:900px;height:84px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702738_113-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702738_113 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&price=AAAAAF1M7dAAAAAAAAIqWEMqFUs4PYgNFskKbg==&finfo=DAABCAABAAAASAgAAgAAAD0EAAM/UY/Lcqx6zwAIAAIAAAADCgADDIbzpG+idqAIAAQAAABDBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkwA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FejnJBWkhJ4CFaD1xhUVwI36WBUGFRwWuonH+hQW+N+kupnp+YYZNAIWqOAQJQYVvci32AMVngEVACQUFujnJAA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=aV75QrTCu0Z=&url=http%3A%2F%2Fbaidu.code.jjyx.com%2Fhtmlcode%2F24889.html%3Fsourceid%3D%7Bsource_id%7D" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAASAgAAgAAAD0EAAM/UY/Lcqx6zwAIAAIAAAADCgADDIbzpG+idqAIAAQAAABDBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkwA&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FejnJBWkhJ4CFaD1xhUVwI36WBUGFRwWuonH+hQW+N+kupnp+YYZNAIWqOAQJQYVvci32AMVngEVACQUFujnJAA&ds=1&price=AAAAAF1M7dAAAAAAAAIqWEMqFUs4PYgNFskKbg==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoAWIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=jC92AwAAAAA=&w=AAAAAF1M7dAAAAAAAAIqgE_cxELWHLgFLii0bg&i=OLWZaQtF9J3J&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoAWIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=1wepnwAAAAA=&i=OLWZaQtF9J3J&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/301556-27e49e469ababbb79563a62c9f9d2bab.gif)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">陈小春坦言:这游戏不充钱都能当全服大哥,找到充值入口算我输!</info-div>
<info-div class="singleImage-desc">贪玩游戏 · 顶新</info-div>
</info-div>
Mysql主键、外键运用于关联查
03-10 阅读数 483
8.Mysql多表查询1.user表2.message表目标:只知道username=‘tom’查询出tom的phonesql;SELECTphoneFROMuseru,messagemWHEREu.... 博文 来自: 前行的力量,永不停歇!
MySQL外键的使用、更新或者删除主键的时候同时对从表做操作
03-12 阅读数 253
首先,如何定义一个外键。需要两个表,一个主表,一个从表。student表(从表)grade表(主表)从表中有一个属性对应的是主表中的主键或者其他唯一的键。在这个例子中国student表的gid就是对应... 博文 来自: weixin_36193572的博客
<div class="recommend-item-box blog-expert-recommend-box" style="">
<div class="d-flex">
<div class="blog-expert-recommend">
<div class="blog-expert">
<div class="blog-expert-flexbox"></div>
</div>
</div>
</div>
</div>
mysql 数据库 操作 获取某一个表的所有信息 主键 外键 类型
10-07 阅读数 2476
SELECT* FROMinformation_schema.columnsaJOIN information_schema.TABLESbONa.table_schema=b.table_schem... 博文 来自: sinat_19528249的博客
[一点笔记]主键与外键-MySQL中的表连接
11-21 阅读数 1502
关系型数据库中的一条记录中有若干个属性,若其中某一个属性组(注意是组)能唯一标识一条记录,该属性组就可以成为一个主键。比如: 学生表(学号,姓名,性别,班级) 其中每个学生的学号是唯一的,学号就是... 博文 来自: saiofo的博客
MySQL教程之主键与外键的作用及使用
08-06 阅读数 669
CREATETABLETABLE_1(IDINTUNSIGNEDNOTNULLPRIMARYKEYAUTO_INCREMENT,//ID列为无符号整型,该列值不可以为空,并不可以重复,而且自增。NAM... 博文 来自: qq3285862072的博客
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_61" data-pid="61" data-track-view="{"mod":"kp_popu_61-557","con":",,"}" data-track-click="{"mod":"kp_popu_61-557","con":",,"}" data-report-view="{"mod":"kp_popu_61-557","keyword":""}" data-report-click="{"mod":"kp_popu_61-557","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702793_432" id="QIHOO__WEB__SO__1565322702793_432" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702793_432-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702793_432 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&price=AAAAAF1M7dAAAAAAAAOL3Rhf+NWqW2h9yXRRQw==&finfo=DAABCAABAAAAHwgAAgAAAB0EAAM/TX4r+uhWJAAIAAIAAAADCgADDnptgNasvsoIAAQAAAAiBgAGK4UGAAoAAAgADgAAABcKAA8AAAAAAAS68AA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FZCnLxXG4MICFayMlhcVvOySWBUGFRwWhJvTwRQW+N/ryZ/gtvocNAIWqMAQJQYV2sm/pQQV/gQVADbNw4jTuKGHrt0BAA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&csign2=aIBSdpX6D1-=&url=http%3A%2F%2F5a960afed3532.site.mvad.com%2F" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAAHwgAAgAAAB0EAAM/TX4r+uhWJAAIAAIAAAADCgADDnptgNasvsoIAAQAAAAiBgAGK4UGAAoAAAgADgAAABcKAA8AAAAAAAS68AA&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FZCnLxXG4MICFayMlhcVvOySWBUGFRwWhJvTwRQW+N/ryZ/gtvocNAIWqMAQJQYV2sm/pQQV/gQVADbNw4jTuKGHrt0BAA&ds=1&price=AAAAAF1M7dAAAAAAAAOL3Rhf+NWqW2h9yXRRQw==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoAWIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=7vsdowAAAAA=&w=AAAAAF1M7dAAAAAAAAOMGAi_rO9Ryz1Q6-HuSg&i=CQ_EqMtF9Jgy&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoAWIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=3THyrwAAAAA=&i=CQ_EqMtF9Jgy&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://p4.ssl.qhimgs0.com/dmsmty/180_100_100/t019ec1b1926ea48f46.jpg)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">喜讯:~面对众多笔记本内存品牌,一招解决如何选购.</info-div>
<info-div class="singleImage-desc">xiyi · 顶新</info-div>
</info-div>
MySQL中主键与外键的区别和联系
03-31 阅读数 9218
主键与外键的关系,通俗点儿讲,我现在有一个论坛,有两张表,一张是主贴thread,一张是回帖reply先说说主键,主键是表里面唯一识别记录的字段,一般是帖子id,体现在访问的时候,例如是thread.... 博文 来自: ......
MySQL如何创建主键,外键和复合主键
12-12 阅读数 1万+
1.主键语法①创建时:createtablesc( studentno int, courseid int, score int, primarykey(studentno... 博文 来自: wqssrs
MySQL建表,主键,外键
09-18 阅读数 1万+
1.创建表MySql中,创建表是通过SQL语句createtable实现的。语法形式如下:createtable表名(属性名数据类型[完整性约束条件], 属性名数据类型[完整性约束条件... 博文 来自: 光线技术博客
mysql主键增加/删除,外键增加/删除,修改表结构
01-07 阅读数 270
1.修改表结构增加表字段:altertableCategoriesaddcolumntitle varchar(255);删除表字段:altertableCategoriesdropcolumntit... 博文 来自: CS13477062349的博客
mysql多对多的关系如何表示(主键也可做外键)
11-20 阅读数 940
mysql>CREATETABLEcourse(->course_NOINTPRIMARYKEY->);QueryOK,0rowsaffected(0.19sec)mysql>mysql>CREATE... 博文 来自: 大海蓝天的专栏
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_62" data-pid="62" data-track-view="{"mod":"kp_popu_62-556","con":",,"}" data-track-click="{"mod":"kp_popu_62-556","con":",,"}" data-report-view="{"mod":"kp_popu_62-556","keyword":""}" data-report-click="{"mod":"kp_popu_62-556","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702810_573" id="QIHOO__WEB__SO__1565322702810_573" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702810_573-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702810_573 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&price=AAAAAF1M7dAAAAAAAAIq3RAk80z9Tx8LrGKjuQ==&finfo=DAABCAABAAAANAgAAgAAADkEAAM/TCVlundo2wAIAAIAAAADCgADDIb8vaqXe9oIAAQAAAA8BgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkgA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FeLnJBXaoK8CFZ69sxYVpPumWxUGFSIW/oHH+hQW+N+5oaOv/oYZNAQWqOAQJQYV0I6j+QMVngEVACQUFuLnJAA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=ELYW1NkCL3Z=&url=http%3A%2F%2Fbaidu.code.mytanwan.com%2Fhtmlcode%2F26374.html" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAANAgAAgAAADkEAAM/TCVlundo2wAIAAIAAAADCgADDIb8vaqXe9oIAAQAAAA8BgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkgA&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FeLnJBXaoK8CFZ69sxYVpPumWxUGFSIW/oHH+hQW+N+5oaOv/oYZNAQWqOAQJQYV0I6j+QMVngEVACQUFuLnJAA&ds=2&price=AAAAAF1M7dAAAAAAAAIq3RAk80z9Tx8LrGKjuQ==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoAmIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=DMNvPQAAAAA=&w=AAAAAF1M7dAAAAAAAAIrAHHJhXS8LAACLhnAJQ&i=OLmZaQtF9Jgi&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoAmIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=eOSL8gAAAAA=&i=OLmZaQtF9Jgi&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/301553-267cf6b7dafaed55b2b9d4f69f1ede29.gif)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">别再玩假传奇了!这款传奇爆率9.8,你找到充值入口算我输!</info-div>
<info-div class="singleImage-desc">贪玩游戏 · 顶新</info-div>
</info-div>
Mysql中一个表的外键是另一个表的主键是否会影响
07-14 阅读数 1755
一共有三张表room表中的id作为父表的主键,另外两个表中的r_id作为子表的外键并且给room表的id设置了字段增加的属性。通过SHOWCREATETABLEroom;可以读到当前AUTO_INCR... 博文 来自: yichu_123的博客
MySql入门之一:DDL操作创建表(添加主键, 外键约束以及基本的数据类型)
03-05 阅读数 7060
创建外键,声明主键的方式小结,mysql,主键,外键,数据类型,5.mysql数据类型 博文 来自: duoluodezhu0826的博客
浅谈 MySQL 中对字段的主键约束、外键约束以及复合主键的用法及好处
06-07 阅读数 829
我们学习数据库肯定是离不开表table的,而刚学到这一块知识时研究了好久,这一块语法有点绕或者难以理解和有点复杂。我说说我学到这里的一些经验吧。...... 博文 来自: weixin_42167594的博客
【Mysql】数据库设计三范式,主键表,外键
10-27 阅读数 3267
一、数据库设计三范式1NF:要求一张表只描述一件事。比如学生表只能保存学生信息,和学生无关的信息不得保存;2NF:要求保证表中每一行数据的原子性。即表中不得存在完全相同的数据行,存在完全相同的数据行叫... 博文 来自: Albert
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_63" data-pid="63" data-track-view="{"mod":"kp_popu_63-555","con":",,"}" data-track-click="{"mod":"kp_popu_63-555","con":",,"}" data-report-view="{"mod":"kp_popu_63-555","keyword":""}" data-report-click="{"mod":"kp_popu_63-555","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702827_265" id="QIHOO__WEB__SO__1565322702827_265" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702827_265-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702827_265 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&price=AAAAAF1M7dAAAAAAAAOMq9Yc3Ob752q7VUBAOA==&finfo=DAABCAABAAAAFwgAAgAAABgEAAM/RVqtuzQX9AAIAAIAAAADCgADDnp2mWtnm2EIAAQAAAAjBgAGLbcGAAoAAAgADgAAABcKAA8AAAAAAAOCcAA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FeLwVhWA7+oCFfbN3hgV/JbfWxUEFSIW0pfJrRcW+N+Asammu/ocNAQWqMAQJQYVlpiunwQVpgQVADbM89+c44/ztZABAA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=UOlBKuNDpi2=&url=http%3A%2F%2Fyhbb.wfc810.com%2Findex.php%3Fm%3DOrder%26id%3DD5360post1%26uid%3D1%26tpl%3Ddetail%26ac%3Dw118.2" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAAFwgAAgAAABgEAAM/RVqtuzQX9AAIAAIAAAADCgADDnp2mWtnm2EIAAQAAAAjBgAGLbcGAAoAAAgADgAAABcKAA8AAAAAAAOCcAA&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FeLwVhWA7+oCFfbN3hgV/JbfWxUEFSIW0pfJrRcW+N+Asammu/ocNAQWqMAQJQYVlpiunwQVpgQVADbM89+c44/ztZABAA&ds=2&price=AAAAAF1M7dAAAAAAAAOMq9Yc3Ob752q7VUBAOA==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoAmIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=s+6YGQAAAAA=&w=AAAAAF1M7dAAAAAAAAOM8pl2sqE8YuYCfE6oqg&i=CQHEqMtF9JgR&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoAmIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=uYJJzwAAAAA=&i=CQHEqMtF9JgR&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/711729-6f3512474389dc21467d95812ebb94bb.jpg)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">我发誓:这酒比1500元的酒还要好喝!</info-div>
<info-div class="singleImage-desc">五分场健康 · 顶新</info-div>
</info-div>
Mysql-基本练习(07-修改表-添加主键、唯一、外键约束、添加/删除默认约束、删除约束)
05-16 阅读数 1657
有任何问题加群讨论,还可以领取精美学习资料噢~群号:733899823加群时请备注CSDN~1.添加主键约束语法:ALTERTABLEtb_nameADD[CONSTRAINT[symbol]]PRI... 博文 来自: Devilyang的博客
MySQL 大哥(主键)跟小弟(外键)
05-30 阅读数 538
主键跟外键之间的关系,就好比说,网站里的谋篇文章,文章有一个文章ID,文章的评论有多条,每条评论又有一个评论ID,评论人,评论内容等相关信息。如果想要删除这篇文章。那就得去评论表里找相关的信息,然后删... 博文 来自: Alicia_N的博客
mysql 外键(foreign key)的使用,同一个table的两个外键对应一个table的主键
02-10 阅读数 6200
官方语法:[CONSTRAINT[symbol]]FOREIGNKEY[index_name](index_col_name,...)REFERENCEStbl_name(index_col_name... 博文 来自: Kirito_j的博客
mysql中设计自增主键id和外键关联时注意
04-18 阅读数 2716
作为一个提醒1.如果a表和b表是1对1,和c表是对多这时,在b表里设置外键a_id,关联a表的主键;c是多的一方,就是子表,在c表加外键a_id,关联a表的主键;然后a,b,c三表主键自增;2.因为a... 博文 来自: shunzi1046的博客
MySQL中的查询约束语句和主键、联合主键、外键
03-20 阅读数 1498
查询语句过滤空值过滤空值如果该值是空的就当做0来处理SELECTIFNULL(字段名,0)FROM表名聚合函数排序利用ORDERBY关键字来约束表按照什么条件来排序ASC代表升序也是默认的DESC代表... 博文 来自: SuPrEeMm的博客
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_64" data-pid="64" data-track-view="{"mod":"kp_popu_64-81","con":",,"}" data-track-click="{"mod":"kp_popu_64-81","con":",,"}" data-report-view="{"mod":"kp_popu_64-81","keyword":""}" data-report-click="{"mod":"kp_popu_64-81","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702860_802" id="QIHOO__WEB__SO__1565322702860_802" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702860_802-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702860_802 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&price=AAAAAF1M7dAAAAAAAAIrW21h6UZBFj8vfUClBw==&finfo=DAABCAABAAAANwgAAgAAACIEAAM/VQIPj9g9SQAIAAIAAAADCgADDIcF1WS0hhsIAAQAAAAmBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkQA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FZDmJBW+2sYCFdbnqBcVnue+WBUGFSIWmo3H+hQW+N/OiK31gocZNAYWqOAQJQYVnMTE/gUVngEVACQUFpDmJAA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=OpO4Um1u22-=&url=http%3A%2F%2Fy.code.17tanwan.com%2Fhtmlcode%2F37386.html" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAANwgAAgAAACIEAAM/VQIPj9g9SQAIAAIAAAADCgADDIcF1WS0hhsIAAQAAAAmBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkQA&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=FZDmJBW+2sYCFdbnqBcVnue+WBUGFSIWmo3H+hQW+N/OiK31gocZNAYWqOAQJQYVnMTE/gUVngEVACQUFpDmJAA&ds=3&price=AAAAAF1M7dAAAAAAAAIrW21h6UZBFj8vfUClBw==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoA2IXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=+zFJJQAAAAA=&w=AAAAAF1M7dAAAAAAAAIrixg6F0yaJ7MeigX_NQ&i=O_PZaQtF9J3p&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoA2IXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=JvUjigAAAAA=&i=O_PZaQtF9J3p&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/301448-abeeb273809c18bd15e1df9bcf4a4f25.gif)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">陈小春哭诉:北京土豪怒砸2亿请他代言这款0充值正版传奇!真经典!</info-div>
<info-div class="singleImage-desc">贪玩游戏 · 顶新</info-div>
</info-div>
复合主键其中之一不能作外键
06-14 阅读数 63
如A表的PA,PB,PC是复合主键,则PA不能作为B表的外键只能PA,PB,PC组成B表的复合外键... 博文 来自: Fight for MyLife
(八)MySQL基础——主键、外键、修改表时添加删除约束、标识列
10-22 阅读数 147
一、主键和唯一的区别: 保证唯一性 是否允许为空 一个表可以有多少个 是否允许组合 主键 √ × 至多有1个 √,但不推荐 唯一 √ √ ... 博文 来自: Steriles_的博客
终于把 MySQL 的主外键搞懂了
10-04 阅读数 7062
基础是我的前面一篇关于主外键的关系的文章首先创建3张表,并插入相应的数据:createtablestudent(sidint(10)primarykeynotnull,namechar(120),se... 博文 来自: 只为成功找方法 不为失败找借口
MySQL数据库--外键约束及外键使用
11-18 阅读数 1万+
什么是主键、外键关系型数据库中的一条记录中有若干个属性,若其中某一个属性组(注意是组)能唯一标识一条记录,该属性组就可以成为一个主键。比如:学生表(学号,姓名,性别,班级)其中每个学生的学号是唯一的,... 博文 来自: Paranoid
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_65" data-pid="65" data-track-view="{"mod":"kp_popu_65-84","con":",,"}" data-track-click="{"mod":"kp_popu_65-84","con":",,"}" data-report-view="{"mod":"kp_popu_65-84","keyword":""}" data-report-click="{"mod":"kp_popu_65-84","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702873_261" id="QIHOO__WEB__SO__1565322702873_261" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702873_261-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702873_261 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&price=AAAAAF1M7dAAAAAAAAONTNEAYkaXukh5Rc0/0A==&finfo=DAABCAABAAAADwgAAgAAAB0EAAM/QJFjCuqrCgAIAAIAAAADCgADDnp/sfUtruwIAAQAAAAdBgAGF2UGAAoAAAgADgAAABcKAA8AAAAAAALmMQA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FdClLxWU6N8CFZzT1RgVnqfQWxUGFSIWqrDR8RMW+N+VmLPsv/ocNAYWqMAQJQYVuKKm1gcVngEVADaP4tXNluKAjkcA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=XdBw06H8tf-=&url=https%3A%2F%2Fdev.tg.wan.360.cn%2F%3Fchannel%3D224440034%26placeid%3D%26creativeid%3D%7Bcreativeid%7D" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAADwgAAgAAAB0EAAM/QJFjCuqrCgAIAAIAAAADCgADDnp/sfUtruwIAAQAAAAdBgAGF2UGAAoAAAgADgAAABcKAA8AAAAAAALmMQA&mv_ref=blog.csdn.net&enup=CAABJG52VAgAAlR2biQA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b430e82725&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbN2JPajK/EhWkVAAAA&uai=FaixkwIlAhUEFvjf1uKVmrL6HBXyCCWxtO+eCiUAFRoUABwWgpSh/ofL6pxMFQAAAA&ubi=FdClLxWU6N8CFZzT1RgVnqfQWxUGFSIWqrDR8RMW+N+VmLPsv/ocNAYWqMAQJQYVuKKm1gcVngEVADaP4tXNluKAjkcA&ds=3&price=AAAAAF1M7dAAAAAAAAONTNEAYkaXukh5Rc0/0A==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoA2IXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=iuu0HQAAAAA=&w=AAAAAF1M7dAAAAAAAAONg9q7zTWef9olXlzcEg&i=CLhEqMtF9JhN&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0MzBlODI3MjUY1NiJASCisEUoA2IXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=fvV52wAAAAA=&i=CLhEqMtF9JhN&exp=BQBECgBECAFEAQJEEgJEEABDIwBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/387432-12c23c475fd15774d7bbb0203f02a354.gif)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">全天无限刷BOSS,装备靠打,交易自由,错过这款,再等一年!</info-div>
<info-div class="singleImage-desc">热血战歌创世 · 顶新</info-div>
</info-div>
MySQL主键、外键以及子表的删除、更新约束
11-26 阅读数 2184
1、什么是主键、外键主键是指数据表中能唯一识别一条记录,并且被设置为 PRIMARY KEY的字段。主键可以是一个单一的字段,也可以是联合的多个字段。比如,下面建表SQL中就将userId设置为主键。... 博文 来自: Brant's Notes
MySQL入门——修改数据表4:添加主键约束、显示表结构、添加唯一约束、添加外键约束
06-05 阅读数 1548
这里的添加主键约束、添加唯一约束,指的是列级约束,是在数据表创建以后再添加的。 例如,给user3表中的id字段添加主键约束:ALTERTABLEuser3ADDPRIMARYKEY(id);例如,给... 博文 来自: _lowbee瞎搞
mysql基本约定与命名规范
10-20 阅读数 8024
一、约定1、如无特殊需求,所有表使用innodb引擎2、如无特殊需求,所有主键均为自增类型3、如无特殊需求,所有字段均为NOTNULL,并给定默认值4、所有字段均设置备注,枚举字段需要说明每个枚举值的... 博文 来自: learsea的专栏
mysql 表基本操作(创建表、添加主键、外键、非空约束、唯一性约束、默认约束、自动增加)
06-17 阅读数 3076
1、单字段主键:createtabletb_emp(idint(11)primarykey,namevarchar(25),depIdint(11),salaryfloat);primarykey指定... 博文 来自: qq_33792097的博客
MySQL中的约束(非空,主键,唯一,外键)
09-02 阅读数 2443
约束*概念:对表中的数据进行限定,保证数据的正确性、有效性和完整性。*分类:1.主键约束:primarykey2.非空约束:notnull3.唯一约束:unique4.外键约束:foreignkey*... 博文 来自: weixin_43118517的博客
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_66" data-pid="66" data-track-view="{"mod":"kp_popu_66-87","con":",,"}" data-track-click="{"mod":"kp_popu_66-87","con":",,"}" data-report-view="{"mod":"kp_popu_66-87","keyword":""}" data-report-click="{"mod":"kp_popu_66-87","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702886_545" id="QIHOO__WEB__SO__1565322702886_545" style="display:block;margin:0;padding:0;border:none;width:852px;height:60px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702886_545-info" style="zoom:1"><info-div class="QIHOO__WEB__SO__1565322702886_545 singleImage clk" data-href="https://ssxd.mediav.com/s?type=2&r=20&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&price=AAAAAF1M7dAAAAAAAAIr3SxEvUIsW+EZ4T65mw==&finfo=DAABCAABAAAASQgAAgAAACEEAAM/YDebj/xtSAAIAAIAAAADCgADDIcO7fiCxPEIAAQAAAAlBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkAA&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=Fb6sNxXgh8YCFeTipRcV0ujGWhUGFRwW3Nef/xUW+N/j77a7h4cZNAgWqOAQJQYVjIO48QYVngEVACQOFr6sNwA&clickid=0&cpx=__OFFSET_X__&cpy=__OFFSET_Y__&cs=__EVENT_TIME_START__&ce=__EVENT_TIME_END__&ldtype=2&csign2=ELYW1NkCL3Z=&url=http%3A%2F%2Fbaidu.code.mytanwan.com%2Fhtmlcode%2F37123.html" data-pv="https://ssxd.mediav.com/s?type=1&r=20&tid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&finfo=DAABCAABAAAASQgAAgAAACEEAAM/YDebj/xtSAAIAAIAAAADCgADDIcO7fiCxPEIAAQAAAAlBgAGG4sGAAoAAAgADgAAACUKAA8AAAAAAAsjkAA&mv_ref=blog.csdn.net&enup=CAABfM2e8ggAAvKezXwA&mvid=NzgxMDUzNjg3NTAxNjA5MzAwNjAwMTk&bid=1384a9b4376c087d&ugi=FcTgigEVyNtrTBUCFSgVKBUAABXAr9JdJcgBFoDQ2Pvi6ccFHBbsovropPPvsg0VAAAA&uai=FeTGlAIlAhUEFvjfj9OPo/WGGRXyCCWzvb/hBCUAFRoUABwWtNPMzISU3otMFQAAAA&ubi=Fb6sNxXgh8YCFeTipRcV0ujGWhUGFRwW3Nef/xUW+N/j77a7h4cZNAgWqOAQJQYVjIO48QYVngEVACQOFr6sNwA&ds=4&price=AAAAAF1M7dAAAAAAAAIr3SxEvUIsW+EZ4T65mw==,https://max-l.mediav.com/rtb?type=2&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoBGIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTmIAQA&k=rIlwawAAAAA=&w=AAAAAF1M7dAAAAAAAAIr_mbEdAsXlBUmVUytSw&i=O_WZaQtF9J3H&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&z=1" data-clk="https://max-l.mediav.com/rtb?type=3&ver=1&v=CGQSEDEzODRhOWI0Mzc2YzA4N2QYsqOKASCisEUoBGIXNzgxMDUzNjg3NTAxNjA5MzAwNjAwMTlwAA&k=GO19lwAAAAA=&i=O_WZaQtF9J3H&exp=BQBECgBECAFEAQJEEgJEEABDJQBD&x=__OFFSET_X__&y=__OFFSET_Y__&st=__EVENT_TIME_START__&et=__EVENT_TIME_END__&adw=__ADSPACE_W__&adh=__ADSPACE_H__&tc=&turl=">
<info-div class="wrap">
<info-div class="singleImage-img singleImage-img-left">
<info-div class="img" style="background-image:url(https://s3m.mediav.com/galileo/453407-422303c83f37f67075642b39a2de926f.gif)"><info-div class="ads-tag"></info-div></info-div>
</info-div>
<info-div class="singleImage-body singleImage-body-left">
<info-div class="singleImage-title">这变态传奇你卸载算我输!爆率9.8,不花一分钱,刀刀爆橙装!</info-div>
<info-div class="singleImage-desc">贪玩游戏 · 顶新</info-div>
</info-div>
MySQL基础,主键,外键,唯一键
01-19 阅读数 37
MySQLMySQL基础上一篇MySQL基础语法MySQL简介以及MySQL中InnoDB与MyISAM引擎的区别主键格式:primarykey用来约束该字段中数据(是唯一的),不能重复,不能为空,一... 博文 来自: 瘦子de啤酒肚的博客
mysql新建表,对表主键外键操作
07-27 阅读数 3578
创建表CREATETABLECustomers(cust_idchar(10)NOTNULL,cust_namechar(50)NOTNULL,cust_addresschar(50)NULL,cus... 博文 来自: Vincent
MySQL数据库中主键和外键的操作
10-29 阅读数 403
在MySQL数据库中,一般会涉及到主键和外键,在上一个表中添加了主键之后,通常在下一个表中要添加外键,但是添加了外键之后,在实体类和数据库中在加上上一个表的主键会比较好,这样两个表关联之后,在上一个表... 博文 来自: wyqwilliam的博客
mysql 如何建立外键
03-07 阅读数 135
最新的成功写法,不要每次都来找了:altertabletb_car_profile addconstraintfk_caridforeignkey(carid)referencestb_car(ca... 博文 来自: germmy-神一样的开发
数据库主键、外键和索引理解
09-14 阅读数 687
主键 外键 索引 定义: 唯一标识一条记录,不能有重复的,不允许为空 表的外键是另一表的主键,外键可以有重复的,可以是空值 该字段没有重复值,但可以有一个空值 作用:... 博文 来自: kepengs的博客
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_67" data-pid="67" data-track-view="{"mod":"kp_popu_67-653","con":",,"}" data-track-click="{"mod":"kp_popu_67-653","con":",,"}" data-report-view="{"mod":"kp_popu_67-653","keyword":""}" data-report-click="{"mod":"kp_popu_67-653","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702902_924" id="QIHOO__WEB__SO__1565322702902_924" style="display:block;margin:0;padding:0;border:none;width:900px;height:84px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702902_924-info" style="zoom:1"></info-div></newsfeed></div>
PowerDesigner主键外键唯一键设置
09-01 阅读数 7972
PowerDesigner主键外键唯一设置 这两天一直在用这个软件做表,一键生成数据库着实是方便。就是主外键唯一键之间的联系一次搞不懂,查了好久资料。搞懂了。记录一下。 约定:1. 默认的是P... 博文 来自: a514166761的博客
查看mysql所有的主键,外键约束名称
09-08 阅读数 1万+
select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE 博文 来自: flymoringbird的博客
MySQL--修改数据表5:删除主键约束,唯一约束,外键约束
06-05 阅读数 1827
以下删除的各种约束,都是只删除约束,并没有删除字段。删除约束后,字段仍然存在例如给users2表中的id字段删除主键约束ALTERTABLEusers2DROPPRIMARYKEY;//这里删除主键不... 博文 来自: _lowbee瞎搞
<div class="recommend-item-box recommend-ad-box"><div id="kp_box_68" data-pid="68" data-track-view="{"mod":"kp_popu_68-654","con":",,"}" data-track-click="{"mod":"kp_popu_68-654","con":",,"}" data-report-view="{"mod":"kp_popu_68-654","keyword":""}" data-report-click="{"mod":"kp_popu_68-654","keyword":""}"><div class="mediav_ad"><newsfeed class="newsfeed QIHOO__WEB__SO__1565322702924_747" id="QIHOO__WEB__SO__1565322702924_747" style="display:block;margin:0;padding:0;border:none;width:900px;height:84px;overflow-y:hidden;overflow-x:hidden;position:relative;text-align:left;"><info-div id="QIHOO__WEB__SO__1565322702924_747-info" style="zoom:1"></info-div></newsfeed></div>
mysql表怎么设置一个表的外键是另一张表的主键 怎么设置外键?
11-23 阅读数 3291
表与表之间有一对多、多对多的关系,只要涉及到表与表之间的关联们就会涉及到外键和主键知识点: 那么怎么设置外键呢?demo:现在有两张表,user表(编号、姓名、职务、工种、部门)、kinds表 (工种... 博文 来自: 信徒博客
<div class="recommend-item-box type_hot_word">
<div class="content clearfix" style="width: 712px;">
<div class="word float-left">
<span>
<a href="https://edu.csdn.net/courses/o5329_s5330_k " target="_blank">
机器学习教程 </a></span>
<span>
<a href="https://edu.csdn.net/courses/o280_s351_k " target="_blank">
Objective-C培训 </a></span>
<span>
<a href="https://edu.csdn.net/combos/o7115_s388_l0_t " target="_blank">
交互设计视频教程 </a></span>
<span>
<a href="https://edu.csdn.net/course/play/5599/104252 " target="_blank">
颜色模型 </a></span>
<span>
<a href="https://edu.csdn.net/combos/o363_l0_t " target="_blank">
设计制作学习 </a></span>
</div>
</div>
<div class="content clearfix" style="width: 712px;">
<div class="float-left">
<span>
<a href="https://www.csdn.net/gather_24/MtTaEg3sMDM5MS1ibG9n.html" target="_blank">
mysql关联查询两次本表</a>
</span>
<span>
<a href="https://www.csdn.net/gather_10/MtjaIg3sMTUzMy1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
native底部 react</a>
</span>
<span>
<a href="https://www.csdn.net/gather_1b/Ntzagg1sOTU3LWRvd25sb2Fk.html" target="_blank">
extjs glyph 图标</a>
</span>
<span>
<a href="https://www.csdn.net/gather_4a/MtjaUg2sODAtZWR1.html" target="_blank">
数据库课程表的外键</a>
</span>
<span>
<a href="https://www.csdn.net/gather_4a/MtTaQg0sMDItZWR1.html" target="_blank">
数据库课程表的外键</a>
</span>
</div>
</div>
</div>
<div class="recommend-loading-box">
<img src="https://csdnimg.cn/release/phoenix/images/feedLoading.gif">
</div>
<div class="recommend-end-box">
<p class="text-center">没有更多推荐了,<a href="https://blog.csdn.net/" class="c-blue c-blue-hover c-blue-focus">返回首页</a></p>
</div>
</div>
</main>
<aside>
<div id="asideProfile" class="aside-box">
<!-- <h3 class="aside-title">个人资料</h3> -->
<div class="profile-intro d-flex">
<div class="avatar-box d-flex justify-content-center flex-column">
<a href="https://blog.csdn.net/cuixiaoming1994">
<img src="https://avatar.csdn.net/B/9/0/3_cuixiaoming1994.jpg" class="avatar_pic">
<img src="https://g.csdnimg.cn/static/user-reg-year/2x/1.png" class="user-years">
</a>
</div>
<div class="user-info d-flex justify-content-center flex-column">
<p class="name csdn-tracking-statistics tracking-click" data-report-click="{"mod":"popu_379"}">
<a href="https://blog.csdn.net/cuixiaoming1994" class="" id="uid">cuixiaoming1994</a>
</p>
</div>
<div class="opt-box d-flex justify-content-center flex-column">
<span class="csdn-tracking-statistics tracking-click" data-report-click="{"mod":"popu_379"}">
<a class="btn btn-sm btn-red-hollow attention" id="btnAttent">关注</a>
</span>
</div>
</div>
<div class="data-info d-flex item-tiling">
<dl class="text-center" title="33">
<dt><a href="https://blog.csdn.net/cuixiaoming1994?t=1">原创</a></dt>
<dd><a href="https://blog.csdn.net/cuixiaoming1994?t=1"><span class="count">33</span></a></dd>
</dl>
<dl class="text-center" id="fanBox" title="5">
<dt>粉丝</dt>
<dd><span class="count" id="fan">5</span></dd>
</dl>
<dl class="text-center" title="21">
<dt>喜欢</dt>
<dd><span class="count">21</span></dd>
</dl>
<dl class="text-center" title="2">
<dt>评论</dt>
<dd><span class="count">2</span></dd>
</dl>
</div>
<div class="grade-box clearfix">
<dl>
<dt>等级:</dt>
<dd>
<a href="https://blog.csdn.net/home/help.html#level" title="3级,点击查看等级说明" target="_blank">
<svg class="icon icon-level" aria-hidden="true">
<use xlink:href="#csdnc-bloglevel-3"></use>
</svg>
</a>
</dd>
</dl>
<dl>
<dt>访问:</dt>
<dd title="26313">
2万+ </dd>
</dl>
<dl>
<dt>积分:</dt>
<dd title="539">
539 </dd>
</dl>
<dl title="137383">
<dt>排名:</dt>
<dd>13万+</dd>
</dl>
</div>
<div class="personal-home-page"><a target="_blank" href="https://me.csdn.net/cuixiaoming1994">TA的个人主页 ></a></div>
个人分类
最新评论
<div class="aside-box">
<div class="persion_article">
<div class="right_box footer_box csdn-tracking-statistics" data-report-view="{"mod":"popu_475"}"> <div class="contact-box" id="footer-contact-box"><div class="img-box"><a href="https://edu.csdn.net?utm_source=csdn_footer" target="_blank"><img src="https://csdnimg.cn/pubfooter/images/edu-QR.png" alt="CSDN学院" style="padding: 6px;"></a><p class="app-text">CSDN学院</p></div><div class="img-box fr"><img style="padding:6px;" src="https://csdnimg.cn/pubfooter/images/job-QR.png" alt="CSDN企业招聘"><p class="app-text">CSDN企业招聘</p></div></div> <div class="contact-info"> <p><svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M2.167 2h11.666C14.478 2 15 2.576 15 3.286v9.428c0 .71-.522 1.286-1.167 1.286H2.167C1.522 14 1 13.424 1 12.714V3.286C1 2.576 1.522 2 2.167 2zm-.164 3v1L8 10l6-4V5L8 9 2.003 5z" fill="#5c5c5c" fill-rule="evenodd"></path></svg><a href="mailto:webmaster@csdn.net" target="_blank"><span class="txt">kefu@csdn.net</span></a> <em class="width126"><svg t="1538013544186" width="17" height="17" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="23556" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M902.60033922 650.96445566c-18.0718526-100.84369837-94.08399771-166.87723736-94.08399771-166.87723737 10.87530062-91.53186599-28.94715402-107.78733693-28.94715401-107.78733691C771.20003413 93.08221664 517.34798062 98.02553561 511.98620441 98.16348824 506.65661791 98.02553561 252.75857992 93.08221664 244.43541101 376.29988138c0 0-39.79946279 16.25547094-28.947154 107.78733691 0 0-75.98915247 66.03353901-94.0839977 166.87723737 0 0-9.63372291 170.35365477 86.84146124 20.85850523 0 0 21.70461757 56.79068296 61.50407954 107.78733692 0 0-71.1607951 23.19910867-65.11385185 83.46161052 0 0-2.43717093 67.16015592 151.93232126 62.56172014 0 0 108.5460788-8.0932473 141.10300432-52.14626271H526.33792324c32.57991817 44.05301539 141.10300431 52.1462627 141.10300431 52.14626271 154.3235077 4.59843579 151.95071457-62.56172013 151.95071457-62.56172014 6.00095876-60.26250183-65.11385185-83.46161053-65.11385185-83.46161052 39.77647014-50.99665395 61.4810877-107.78733693 61.4810877-107.78733692 96.45219231 149.49514952 86.84146124-20.85850523 86.84146125-20.85850523" p-id="23557" fill="#5c5c5c"></path></svg><a href="http://wpa.b.qq.com/cgi/wpa.php?ln=1&key=XzgwMDE4MDEwNl80ODc3MzVfODAwMTgwMTA2XzJf" class="qqcustomer_s" target="_blank"><span class="txt">QQ客服</span></a></em></p> <p><em class="width126"><svg t="1538012951761" width="17" height="17" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="23083" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M466.4934485 880.02006511C264.6019863 859.18313878 107.13744214 688.54706608 107.13744214 481.14947309 107.13744214 259.68965394 286.68049114 80.14660493 508.14031029 80.14660493s401.00286817 179.54304901 401.00286814 401.00286816v1.67343191C908.30646249 737.58941724 715.26799489 943.85339507 477.28978337 943.85339507c-31.71423369 0-62.61874229-3.67075386-92.38963569-10.60739903 30.09478346-11.01226158 56.84270313-29.63593923 81.5933008-53.22593095z m-205.13036267-398.87059202a246.77722444 246.77722444 0 0 0 493.5544489 0 30.85052691 30.85052691 0 0 0-61.70105383 0 185.07617062 185.07617062 0 0 1-370.15234125 0 30.85052691 30.85052691 0 0 0-61.70105382 0z" p-id="23084" fill="#5c5c5c"></path></svg><a href="http://bbs.csdn.net/forums/Service" target="_blank"><span class="txt">客服论坛</span></a></em> <svg t="1538013874294" width="17" height="17" style="" viewBox="0 0 1194 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="23784" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M1031.29689505 943.85339507h-863.70679012A71.98456279 71.98456279 0 0 1 95.60554212 871.86883228v-150.85178906c0-28.58329658 16.92325492-54.46750945 43.13135785-65.93861527l227.99160176-99.75813425c10.55341735-4.61543317 18.24580594-14.0082445 20.72896295-25.23643277l23.21211998-105.53417343a71.95757195 71.95757195 0 0 1 70.28414006-56.51881307h236.95255971c33.79252817 0 63.02360485 23.5090192 70.28414004 56.51881307l23.21211997 105.53417343c2.48315701 11.25517912 10.17554562 20.62099961 20.72896296 25.23643277l227.99160177 99.75813425a71.98456279 71.98456279 0 0 1 43.13135783 65.93861527v150.85178906A71.98456279 71.98456279 0 0 1 1031.26990421 943.85339507z m-431.85339506-143.94213475c143.94213474 0 143.94213474-48.34058941 143.94213474-107.96334876s-64.45411922-107.96334877-143.94213474-107.96334877c-79.51500637 0-143.94213474 48.34058941-143.94213475 107.96334877s0 107.96334877 143.94213475 107.96334876zM1103.254467 296.07330247v148.9894213a35.97878598 35.97878598 0 0 1-44.15700966 35.03410667l-143.94213473-33.57660146a36.0057768 36.0057768 0 0 1-27.80056231-35.03410668V296.1002933c-35.97878598-47.98970852-131.95820302-71.98456279-287.91126031-71.98456279S347.53801649 248.11058478 311.53223967 296.1002933v115.385829c0 16.73431906-11.52508749 31.25538946-27.80056233 35.03410668l-143.94213473 33.57660146A35.97878598 35.97878598 0 0 1 95.63253297 445.06272377V296.07330247C162.81272673 152.13116772 330.77670658 80.14660493 599.47049084 80.14660493s436.63077325 71.98456279 503.81096699 215.92669754z" p-id="23785" fill="#5c5c5c"></path></svg>400-660-0108 </p> <p style="text-align:center">工作时间 8:30-22:00</p> </div> <div class="bg-gray"> <div class="feed_copyright"> <p><a class="right-dotte" href="//www.csdn.net/company/index.html#about" target="_blank">关于我们</a><a href="//www.csdn.net/company/index.html#recruit" target="_blank" class="right-dotte">招聘</a><a href="//www.csdn.net/company/index.html#contact" target="_blank" class="right-dotte">广告服务</a> <a href="https://www.csdn.net/gather/A" target="_blank" class="footer_baidu"> 网站地图</a></p> <p class="fz12_baidu"><a href="https://zn.baidu.com/cse/home/index" target="_blank"><svg width="13" height="14" xmlns="http://www.w3.org/2000/svg"><path d="M8.392 7.013c1.014 1.454 2.753 2.8 2.753 2.8s1.303 1.017.47 2.98c-.833 1.962-3.876.942-3.876.942s-1.122-.36-2.424-.072c-1.303.291-2.426.181-2.426.181s-1.523.037-1.957-1.888c-.434-1.927 1.52-2.982 1.666-3.161.145-.183 1.159-.873 1.81-1.963.653-1.09 2.608-1.962 3.984.181zm1.23 5.706V9.346H8.64v2.534h-.937s-.3-.044-.356-.285V9.33l-.925.015v2.518s.042.627.925.855h2.277zm-3.685.013V7.951l-.896-.014v1.295H3.987s-1.054.086-1.422 1.28c-.129.798.114 1.266.156 1.368.043.099.383.682 1.238.852h1.978zm-2.433-1.45c-.087-.286.013-.613.057-.741.042-.128.228-.427.61-.54h.855v1.948h-.797s-.555-.029-.725-.668zm6.877-8.775c-.143.909-.865 2.108-1.99 1.962-1.121-.144-1.375-1.16-1.267-2.179C7.214 1.458 8.21.18 9.007.364c.796.18 1.52 1.235 1.374 2.143zm-4.09-.345c0 1.197-.68 2.164-1.52 2.164S3.25 3.36 3.25 2.162C3.25.967 3.932 0 4.77 0c.842 0 1.52.967 1.52 2.162zm4.854 2.09c1.34 0 1.701 1.309 1.701 1.743 0 .438.182 2.29-1.485 2.326-1.667.037-1.737-1.126-1.737-1.96 0-.874.179-2.11 1.52-2.11zm-7.93.581c.045.398.253 2.217-1.27 2.544C.427 7.704-.14 5.947.028 5.124c0 0 .18-1.78 1.412-1.89.98-.085 1.7.986 1.774 1.6z" fill="#999" fill-rule="evenodd"></path></svg><em>百度提供站内搜索</em></a> <a href="http://www.miibeian.gov.cn/publish/query/indexFirst.action" target="_blank" class="ml14">京ICP备19004658号</a></p> <p class="fz12_baidu">©1999-2019 北京创新乐知网络技术有限公司 </p> </div> </div> <div class="allow-info-box"> <p><a href="https://csdnimg.cn/cdn/content-toolbar/csdn-ICP.png" target="_blank">经营性网站备案信息</a> <em class="width126"><a href="http://www.cyberpolice.cn/" target="_blank"><span>网络110报警服务</span></a></em></p> <p><a href="http://www.bjjubao.org/" target="_blank"><span>北京互联网违法和不良信息举报中心</span></a></p> <p><a href="http://www.12377.cn/" target="_blank"><span>中国互联网举报中心</span></a><a href="https://download.csdn.net/index.php/tutelage/" target="_blank"><span style="margin-left:8px">家长监护</span></a><a href="https://blog.csdn.net/blogdevteam/article/details/90369522" target="_blank"><span style="margin-left:8px">版权申诉</span></a></p> </div> </div></div>
</div>
</div>
qq_38058835:不知楼主能不能把sql文件发下
qq_41639567:写完Oracle,咋不继续写了