mysql> create table cc(id int auto_increment);
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def
ined as a key
mysql> create table cc(id int auto_increment primary key);
Query OK, 0 rows affected (0.03 sec) mysql> desc cc;
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
+-------+---------+------+-----+---------+----------------+
1 row in set (0.01 sec) mysql> mysql> create table abc(id int primary key);
Query OK, 0 rows affected (0.04 sec) mysql>

注意:

自动编号Auto_INCREMENT必须与主键PRIMARY KEY组合使用

primary key可以独自使用

Mysql中的primary key 与auto_increment的更多相关文章

  1. {MySQL完整性约束}一 介绍 二 not null与default 三 unique 四 primary key 五 auto_increment 六 foreign key 七 作业

    MySQL完整性约束 阅读目录 一 介绍 二 not null与default 三 unique 四 primary key 五 auto_increment 六 foreign key 七 作业 一 ...

  2. [MySQL数据库之表的约束条件:primary key、auto_increment、not null与default、unique、foreign key:表与表之间建立关联]

    [MySQL数据库之表的约束条件:primary key.auto_increment.not null与default.unique.foreign key:表与表之间建立关联] 表的约束条件 约束 ...

  3. mySQL中删除unique key的语法 (删除某个字段的唯一性)

    mySQL中删除unique key的语法 CREATE TABLE `good_booked` (  `auto_id` int(10) NOT NULL auto_increment,  `goo ...

  4. MySQL中ON DUPLICATE KEY UPDATE使用

    今天做推断插入用到了MySQL中ON DUPLICATE KEY UPDATE,如今Mark下面! 假设你想做到数据库中没有数据的话插入数据.有数据的话更新数据,那么你能够选择ON DUPLICATE ...

  5. (转)Sqlite中INTEGER PRIMARY KEY AUTOINCREMENT和rowid的使用

    原文:http://www.cnblogs.com/peida/archive/2008/11/29/1343832.html Sqlite中INTEGER PRIMARY KEY AUTOINCRE ...

  6. Mysql中自增字段(AUTO_INCREMENT)的一些常识

    Mysql中自增字段(AUTO_INCREMENT)的一些常识: http://chengxuyuan.naxieshir.com/fenlei/2/p/151.html

  7. MYSQL—— 完整性约束条件中primary key、auto_increment使用总结!

    完整性约束条件主要有:primary key(主键), auto_increment(自增长), poreign key(外键), not null(非空), unique key(唯一), defa ...

  8. Mysql中的索引()key 、primary key 、unique key 与index区别)

    CREATE TABLE pre_forum_post ( pid int(10) unsigned NOT NULL COMMENT '帖子id', fid mediumint(8) unsigne ...

  9. shell脚本检索所有mysql数据库中没有primary key的表

    1.mkdir -p /root/scripts/ 2. cd /root/scripts/ vim query.sql,代码如下: SELECT CONCAT(t.table_schema,&quo ...

随机推荐

  1. Distributed transactions in Spring, with and without XA

    While it's common to use the Java Transaction API and the XA protocol for distributed transactions i ...

  2. poj2299——Ultra-QuickSort

    Description In this problem, you have to analyze a particular sorting algorithm. The algorithm proce ...

  3. Astronauts UVALive - 3713(2-SAT)

    大白书例题 #include <iostream> #include <cstdio> #include <sstream> #include <cstrin ...

  4. 【ListBox】ListBox的相关操作

    Winform中两个listbox的操作是平时比较常用的操作. 本次将以一个Winform实例来分享一下两个listbox的操作,包括:listbox添加项,项的上移下移等操作. 假设有两个listb ...

  5. 【CF954I】Yet Another String Matching Problem(FFT)

    [CF954I]Yet Another String Matching Problem(FFT) 题面 给定两个字符串\(S,T\) 求\(S\)所有长度为\(|T|\)的子串与\(T\)的距离 两个 ...

  6. MSSQL代理工作服务器远程命令执行

    概述 如果MSSQL数据库中开启了MSSQL Server Agent Job服务的话,攻击者将可以利用MSSQL Server中自带的功能来获取一个shell. SQL Server Agent S ...

  7. https的通信过程

    https的特点 1. https有 握手阶段 和 请求阶段2. 握手阶段 使用 非对称加密算法 请求阶段 使用 对称加密算法3. 保证数据的完整性使用数字签名4. 握手阶段有两组非对称加密,数字证书 ...

  8. bzoj1912【Apio2010】patrol 巡逻

    题解: 显然需要分类讨论了,首先理解k==0即原图时按照dfs序来说 , 每条边至少走两次: k==1,相当于可以省去dfs回溯时第二次走过某条路径的浪费,所以答案是k==0的答案-直径 : k==2 ...

  9. [转载]DataView详解

    表示用于排序.筛选.搜索.编辑和导航的 DataTable 的可绑定数据的自定义视图. DataView的功能类似于数据库的视图,他是数据源DataTable的封装对象,可以对数据源进行排序.搜索.过 ...

  10. 【题解】征途 SDOI 2016 BZOJ 4518

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4518 首先推式子,我们用$x_i$表示第$i$段的路程,$sum$表示总路程,根据方差和平均 ...