我正在尝试将AUTO_INCREMENT设置为某个值,但我的语法错误。我不确定它是什么,因为我看了文档,似乎没问题。但是必定有错误。
编辑 - 抱歉,我使用的是mysql phpmyadmin
CREATE TABLE CUSTOMER (
CUSTID int(6) NOT NULL AUTO_INCREMENT = 109,
NAME CHAR (45),
ADDRESS CHAR (40),
CITY CHAR (30),
STATE CHAR (2),
ZIP CHAR (9),
AREA NUMERIC(3),
PHONE CHAR (9),
REPID NUMERIC(4) NOT NULL,
CREDITLIMIT NUMERIC(9,2),
COMMENTS TEXT,
CONSTRAINT CUSTOMER_PRIMARY_KEY PRIMARY KEY (CUSTID),
CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0));
答案 0 :(得分:0)
AUTO_INCREMENT
序列以另一个值开头,您需要单独更改表。CREATE TABLE CUSTOMER (
CUSTID int(6) NOT NULL AUTO_INCREMENT,
NAME CHAR (45),
ADDRESS CHAR (40),
CITY CHAR (30),
STATE CHAR (2),
ZIP CHAR (9),
AREA NUMERIC(3),
PHONE CHAR (9),
REPID NUMERIC(4) NOT NULL,
CREDITLIMIT NUMERIC(9,2),
COMMENTS TEXT,
CONSTRAINT CUSTOMER_PRIMARY_KEY PRIMARY KEY (CUSTID),
CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0));
ALTER TABLE CUSTOMER AUTO_INCREMENT= 109;
答案 1 :(得分:0)
此格式适用于我:
CREATE TABLE CUSTOMER (
CUSTID int(6) NOT NULL AUTO_INCREMENT,
NAME CHAR (45),
ADDRESS CHAR (40),
CITY CHAR (30),
STATE CHAR (2),
ZIP CHAR (9),
AREA NUMERIC(3),
PHONE CHAR (9),
REPID NUMERIC(4) NOT NULL,
CREDITLIMIT NUMERIC(9,2),
COMMENTS TEXT,
AUTO_INCREMENT = 109,
CONSTRAINT CUSTOMER_PRIMARY_KEY PRIMARY KEY (CUSTID),
CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0));