MySQL 表中仅设置一个列为自动增长的插入方式?
我们首先创建一个表:
mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT, -> PRIMARY KEY(StudentId) -> ); Query OK, 0 rows affected (0.60 sec)
使用 insert 命令在表中插入一些记录。在此处,我们插入了一个值,但由于它是自动增长,因此,可以看见默认值:
mysql> insert into DemoTable(StudentId) values(0); Query OK, 1 row affected (0.18 sec)
使用 select 语句显示表中的所有记录:
mysql> select *from DemoTable;
这将会生成以下输出。默认自动增长值为 1,第一个值可见:
+-----------+ | StudentId | +-----------+ | 1 | +-----------+ 1 row in set (0.00 sec)
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP