Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-01 13:48:31
Original
961 people have browsed it

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;
Copy after login
bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!