SQL 创建 table 并设置自动增量值而不更改 table

SQL create table and set auto increment value without Alter table

例如我正在创建以下 table:

CREATE TABLE Persons (
     ID int NOT NULL AUTO_INCREMENT,
     LastName varchar(255) NOT NULL,
     FirstName varchar(255),
     Address varchar(255),
     PRIMARY KEY (ID)
)

据我所知,Auto increment的值可以通过Alter table这样修改

ALTER TABLE Persons AUTO_INCREMENT=100;

但我只想知道有没有办法在创建 table 时设置自动增量的值?
这样的东西?

CREATE TABLE Persons (
     ID int NOT NULL AUTO_INCREMENT = 100,
     LastName varchar(255) NOT NULL,
     FirstName varchar(255),
     Address varchar(255),
     PRIMARY KEY (ID)
)

是的,您可以在创建 table as

时执行此操作
CREATE TABLE Persons (
     ID int NOT NULL AUTO_INCREMENT,
     LastName varchar(255) NOT NULL,
     FirstName varchar(255),
     Address varchar(255),
     PRIMARY KEY (ID)
)AUTO_INCREMENT=100;

这是一个测试用例

mysql> CREATE TABLE Persons (
    ->      ID int NOT NULL AUTO_INCREMENT,
    ->      LastName varchar(255) NOT NULL,
    ->      FirstName varchar(255),
    ->      Address varchar(255),
    ->      PRIMARY KEY (ID)
    -> )AUTO_INCREMENT=100;
Query OK, 0 rows affected (0.13 sec)

mysql> insert into Persons (LastName) values ('CCC');
Query OK, 1 row affected (0.03 sec)

mysql> select * from Persons ;
+-----+----------+-----------+---------+
| ID  | LastName | FirstName | Address |
+-----+----------+-----------+---------+
| 100 | CCC      | NULL      | NULL    |
+-----+----------+-----------+---------+
1 row in set (0.00 sec)

试试这个

  CREATE TABLE Persons (
         ID int NOT NULL AUTO_INCREMENT,
         LastName varchar(255) NOT NULL,
         FirstName varchar(255),
         Address varchar(255),
         PRIMARY KEY (ID)
    )AUTO_INCREMENT=100;