当前位置:网站首页>mysql 联合主键_Mysql 创建联合主键[通俗易懂]
mysql 联合主键_Mysql 创建联合主键[通俗易懂]
2022-07-04 13:55:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
Mysql 创建联合主键
2008年01月11日 星期五 下午 5:21
使用primary key (fieldlist)
比如:
create table mytable (
aa int,
bb char(8),
cc date,
primary key (aa,bb )
);
aa,bb为联合主键
不知道是不是因为mysql(6.0)的版本问题,还是各版本都是这种情况,mysql中创建联合主键,联合主键列名之外不可以用单引号括上,否则出现错误,无法创建,报错是该列在表中不存在。例子代码如下:
CREATE TABLE `book_sort2` (
`sort_id2` varchar(20) NOT NULL,
`sort_id1` varchar(20) NOT NULL COMMENT ‘一类id’,
`sort_name2` varchar(20) NOT NULL COMMENT ‘二类名称’,
PRIMARY KEY (sort_id2,sort_id1),
KEY `sort_id1` (`sort_id1`),
CONSTRAINT `book_sort2_fk` FOREIGN KEY (`sort_id1`) REFERENCES `book_sort1` (`sort_id1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
笔记 oracle 创建联合主键
笔记 alter table tablename add constraint unionkeyname primary key (column1,column2); 上面语句中: tablename …
mysql创建,添加主键
primary key 1.最简单的: CREATE TABLE t1( id int not null, name char(20)); 2.带主键的: a:CREATE TABLE t1( id …
MySQL创建双主键
如下: CREATE TABLE `loginlog` ( `id` ) unsigned zerofill NOT NULL AUTO_INCREMENT COMMENT ‘主键编号’, `IP` …
mysql修改联合主键
参考 https://blog.csdn.net/BockSong/article/details/80933477 alter table TABNAME drop primary key; alt …
SQL 创建联合主键Table
CREATE TABLE [User_Instance]( [IntanceID] [int] NOT NULL, ) NOT NULL ) ON [PRIMARY] GO SET ANSI_PADD …
oracle 主键删除,联合主键的创建
1,主键的删除 ALTER TABLE TABLENAME DROP PRIMARY_KEY 运行上面的SQL能够删除主键:假设不成功能够用 ALTER TABLE TABLENAME DROP C …
Oracle 主键、联合主键的查询与创建
–查询某个表是否有唯一主键 select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = …
Hibernate(5)—— 联合主键 、一对一关联关系映射(xml和注解) 和 领域驱动设计
俗话说,自己写的代码,6个月后也是别人的代码……复习!复习!复习!涉及的知识点总结如下: One to One 映射关系 一对一单向外键(XML/Annotation) 一对一双向外键关联(XML/A …
SQL Server中的联合主键、聚集索引、非聚集索引、mysql 联合索引
我们都知道在一个表中当需要2列以上才能确定记录的唯一性的时候,就需要用到联合主键,当建立联合主键以后,在查询数据的时候性能就会有很大的提升,不过并不是对联合主键的任何列单独查询的时候性能都会提升,但我 …
随机推荐
Collection和Collections的区别?
Collection 是接口(Interface),是集合类的上层接口. Collections是类(Class),集合操作的工具类,服务于Collection框架.它是一个算法类,提供一系列静态方法 …
Spring+Mybatis基于注解整合Redis
基于这段时间折腾redis遇到了各种问题,想着整理一下.本文主要介绍基于Spring+Mybatis以注解的形式整合Redis.废话少说,进入正题. 首先准备Redis,我下的是Windows版,下载 …
js冒泡排序与二分法查找
冒泡排序 var attr=[1,5,7,6,3,9,2,8,4]; var zj=0; //控制比较轮数 for(var i=0;i
hdu 4038 2011成都赛区网络赛H 贪心 ***
贪心策略 1.使负数为偶数个,然后负数就不用管了 2.0变为1 3.1变为2 4.2变为3 5.若此时操作数剩1,则3+1,否则填个1+1,然后回到5
sql where 1=1和 0=1 的作用
sql where 1=1和 0=1 的作用 摘自: http://www.cnblogs.com/junyuz/archive/2011/03/10/1979646.html where 1=1; …
extjs中的下载并对文件重命名功能的实现
在小白的学习extjs的过程中,如果需要了解多文件的上传功能,也可以查看小白的上篇随笔,希望给大家帮助.http://www.cnblogs.com/wangqc/p/extjsFileUpload. …
Hello又大了一岁
时间就这样子过了一年一年一年一年一年…一年一年一年……… 以往每年的生日,都习惯安静的猫在一个地方.时间流逝,更像是一种默默的悼念. 也许从28岁开始,我得习惯用逗比的心态欢迎.长大的 …
REDGATE又一好用的脚本工具ScriptsManager1.3
原文:REDGATE又一好用的脚本工具ScriptsManager1.3 REDGATE又一好用的脚本工具ScriptsManager1.3 先说明一下:这个工具是免费的 下载地址:http://ww …
jQuery中下拉select、复选checkbox、单选radio的操作代码
//select $(“#Icon”) //对象 $(“#Icon”).val() //取值 $(“#Icon”).val(“fa …
HTML Meta信息的优先级
一般来讲meta的信息都是不同维度的不会有冲突,不过下面两个有一定冲突:
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/149326.html原文链接:https://javaforall.cn
边栏推荐
- 产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
- Combined with case: the usage of the lowest API (processfunction) in Flink framework
- C language personal address book management system
- 03-存储系统
- How to build a technical team that will bring down the company?
- Techsmith Camtasia Studio 2022.0.2屏幕录制软件
- Summer Review, we must avoid stepping on these holes!
- Enter the width!
- LVGL 8.2 List
- A keepalived high availability accident made me learn it again
猜你喜欢
Ffprobe common commands
5g TV cannot become a competitive advantage, and video resources become the last weapon of China's Radio and television
Helix swarm Chinese package is released, and perforce further improves the user experience in China
Redis publier et s'abonner
C1 certification learning notes 3 -- Web Foundation
Kubernets Pod 存在 Finalizers 一直处于 Terminating 状态
The performance of major mainstream programming languages is PK, and the results are unexpected
自动控制原理快速入门+理解
How to build a technical team that will bring down the company?
Preliminary exploration of flask: WSGI
随机推荐
SAIC Maxus officially released its new brand "mifa", and its flagship product mifa 9 was officially unveiled!
flutter 报错 No MediaQuery widget ancestor found.
C language course design questions
大神详解开源 BUFF 增益攻略丨直播
Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
曝光一下阿里的工资待遇和职位级别
03 storage system
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
毕业季-个人总结
Introduction to modern control theory + understanding
韩国AI团队抄袭震动学界!1个导师带51个学生,还是抄袭惯犯
[local differential privacy and random response code implementation] differential privacy code implementation series (13)
局部修改-渐进型开发
selenium 元素交互
Quick introduction to automatic control principle + understanding
C language set operation
%f格式符
Numpy notes
LVLG 8.2 circular scrolling animation of a label
C language achievement management system for middle school students