Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 添加自定义自动增量值_Mysql_Sql - Fatal编程技术网

Mysql 添加自定义自动增量值

Mysql 添加自定义自动增量值,mysql,sql,Mysql,Sql,我正在尝试创建一个MySQL,它告诉 自动增量 从何处以及如何开始递增。每次我运行代码时,它总是告诉我有错误 自动的 每次我删除“=”时,它总是有效的 这是密码 CREATE TABLE staff( id into(11) not null primary key auto_increment=001, Names varchar(109) not null ); 我做错了什么?首先创建如下表: 将表staff(id)创建为(11)非空主键 自动递增,名称varchar(109)不为空 然后

我正在尝试创建一个MySQL,它告诉

自动增量

从何处以及如何开始递增。每次我运行代码时,它总是告诉我有错误

自动的

每次我删除“=”时,它总是有效的

这是密码

CREATE TABLE staff(
id into(11) not null primary key auto_increment=001,
Names varchar(109) not null
);

我做错了什么?首先创建如下表:

将表staff(id)创建为(11)非空主键 自动递增,名称varchar(109)不为空

然后改为自定义自动增量

ALTER TABLE staff AUTO_INCREMENT=001

架构(MySQL v5.7)



默认的自动增量值是表上的选项,而不是列上的选项(可能与直觉相反,但一个表只允许有一个这样的列)

语法如下所示:

CREATE TABLE staff (
    id int not null primary key auto_increment,
    Names varchar(109) not null
) auto_increment = 10;

是个骗子。

@ROHIT KHURANA希望你的问题已经解决了。
CREATE TABLE staff (
    id int not null primary key auto_increment,
    Names varchar(109) not null
) auto_increment = 10;