primary key
只要使用innodb就要为表指定主键;
如果不指定mysql就会自己找不为空且为一的作为主键,如果找不到,就会使用默认的(软件自己预定好的)作为主键;
主键分为单列主键和复合主键,用法和单列唯一,联合唯一一样;
copy from oldboy egon;
# 单列主键
create table t17(
id int primary key,
name char(16)
);
create table t18(
id int not null unique,
name char(16)
);
# 复合主键
create table t19(
ip char(15),
port int,
primary key(ip,port)
);
primary key的更多相关文章
- ORA-02429: cannot drop index used for enforcement of unique /primary key
相信不少人遇到过ORA-02429: cannot drop index used for enforcement of unique /primary key 这个错误,对应的中文提示"O ...
- SQL PRIMARY KEY 约束\SQL FOREIGN KEY 约束\SQL CHECK 约束
SQL PRIMARY KEY 约束 PRIMARY KEY 约束唯一标识数据库表中的每条记录. 主键必须包含唯一的值. 主键列不能包含 NULL 值. 每个表都应该有一个主键,并且每个表只能有一个主 ...
- Hibernate Id Generator and Primary Key
Use automate id by hibernate: If you want the tables' id be created automation. How to do it? When u ...
- Database Primary key and Foreign key [From Internet]
Database Primary key and Foreign key --Create Referenced Table CREATE TABLE Department ( DeptID int ...
- SQLite主键自增需要设置为integer PRIMARY KEY
按照正常的SQL语句,创建一个数据表,并设置主键是这样的语句: ), EventType )) 但使用这种办法,在SQLite中创建的的数据表,如果使用Insert语句插入记录,如下语句: INSER ...
- ASP.NET MVC another entity of the same type already has the same primary key value
ASP.NET MVC项目 Repository层中,Update.Delete总是失败 another entity of the same type already has the same pr ...
- 1503 - A PRIMARY KEY must include all columns in the table's partitioning function
1503 - A PRIMARY KEY must include all columns in the table's partitioning function 错误的原因:表的主键字段必须包含分 ...
- (转)Sqlite中INTEGER PRIMARY KEY AUTOINCREMENT和rowid的使用
原文:http://www.cnblogs.com/peida/archive/2008/11/29/1343832.html Sqlite中INTEGER PRIMARY KEY AUTOINCRE ...
- mysql中key 、primary key 、unique key 与index区别
一.key与primary key区别 CREATE TABLE wh_logrecord ( logrecord_id ) NOT NULL auto_increment, ) default NU ...
- Primary key and Unique index
SQL> create table t1(id1 char(2),id2 char(2),id3 char(2)); Table created. SQL> desc t1 Name Nu ...
随机推荐
- 详解 ZooKeeper 数据持久化
本文作者:HelloGitHub-老荀 Hi,这里是 HelloGitHub 推出的 HelloZooKeeper 系列,免费开源.有趣.入门级的 ZooKeeper 教程,面向有编程基础的新手. 项 ...
- cadence Virtuoso ADE原理图AnalogLib库中的switch使用
Symbol: switch A,B:等效于一个电阻; C,D:等效于控制开关(CD间的控制电压控制AB的断开或闭合); open switch resistance:开关断开状态下的等效电阻(AB之 ...
- Java例题_19 打印菱形图案
1 /*19 [程序 19 打印菱形图案] 2 题目:打印出如下图案(菱形) 3 * 4 *** 5 ***** 6 ******* 7 ***** 8 *** 9 * 10 */ 11 12 /*分 ...
- Gateway的限流重试机制详解
前言 想要源码地址的可以加上此微信:Lemon877164954 前面给大家介绍了Spring Cloud Gateway的入门教程,这篇给大家探讨下Spring Cloud Gateway的一些其 ...
- 分库分表之后,id主键如何处理?
(1)数据库自增id 这个就是说你的系统里每次得到一个id,都是往一个库的一个表里插入一条没什么业务含义的数据,然后获取一个数据库自增的一个id.拿到这个id之后再往对应的分库分表里去写入. 这个方案 ...
- Summary: DOM modification techniques
Modifying an existing element We covered various ways that you can modify aspects of an existing ele ...
- hdu1316 水大数
题意: 给你一个区间,问这个区间有多少个斐波那契数. 思路: 水的大数,可以直接模拟,要是懒可以用JAVA,我模拟的,打表打到1000个就足够用了... #include<s ...
- 缓冲区溢出分析第05课:编写通用的ShellCode
前言 我们这次的实验所要研究的是如何编写通用的ShellCode.可能大家会有疑惑,我们上次所编写的ShellCode已经能够很好地完成任务,哪里不通用了呢?其实这就是因为我们上次所编写的ShellC ...
- POJ1422 最小路径覆盖
题意: 一个战场,往战场上投放伞兵,每个伞兵不能后退,只能往前走,问你最少多少个伞兵可以吧所有的点都占领. 思路: 这个题是最小路径覆盖,最小路径覆盖 = n - 最大匹配数,首先 ...
- MS06-040漏洞研究(上)【转载】
课程简介 我在之前的课程中讨论过W32Dasm这款软件中的漏洞分析与利用的方法,由于使用该软件的人群毕竟是小众群体,因此该漏洞的危害相对来说还是比较小的.但是如果漏洞出现在Windows系统中,那么情 ...