要设置字段自增,可以使用SQL语句中的AUTO_INCREMENT属性。以下是使用不同数据库系统的示例:
MySQL和MariaDB:
CREATE TABLE table_name (
column_name INT AUTO_INCREMENT,
other_columns,
PRIMARY KEY (column_name)
);
SQL Server:
CREATE TABLE table_name (
column_name INT IDENTITY(1,1),
other_columns,
PRIMARY KEY (column_name)
);
Oracle:
CREATE TABLE table_name (
column_name INT GENERATED ALWAYS AS IDENTITY,
other_columns,
PRIMARY KEY (column_name)
);
PostgreSQL:
CREATE TABLE table_name (
column_name SERIAL,
other_columns,
PRIMARY KEY (column_name)
);
请注意,这些示例中的"table_name"和"column_name"应替换为实际的表名和列名。