Home  >  Article  >  Database  >  Mysql,SqlServer,Oracle主键自动增长的设置_MySQL

Mysql,SqlServer,Oracle主键自动增长的设置_MySQL

WBOY
WBOYOriginal
2016-06-01 13:48:31953browse

bitsCN.com

参考文献

http://blog.csdn.net/andyelvis/article/details/2446865

1、把主键定义为自动增长标识符类型

MySql

在mysql中,如果把表的主键设为auto_increment类型,数据库就会自动为主键赋值。例如:

create table customers(id int auto_increment primary key not null, name varchar(15));insert into customers(name) values("name1"),("name2");select id from customers;
bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn