create table student( s_id VARCHAR(50) PRIMARY KEY AUTO_INCREMENT, s_gender CHAR(2) UNIQUE NOT NULL, s_birthday datetime DEFAULT '1970-01-01', s_degree VARCHAR(12), s_graduate_date datetime DEFAULT '1970-01-02', s_specialty VARCHAR(50), s_phone VARCHAR(200), s_salary SMALLINT, s_allowance DECIMAL(18,2), s_skill VARCHAR(2000) )为什么会报1063 - Incorrect column specifier for column 's_id'错误
时间: 2024-03-07 16:48:01 浏览: 66
这是因为在MySQL中,VARCHAR类型不能使用AUTO_INCREMENT属性,只有整数类型才能使用AUTO_INCREMENT。因此,将s_id列的类型更改为INT或BIGINT,并将其AUTO_INCREMENT属性设置为主键即可,例如:
```
CREATE TABLE student (
s_id INT PRIMARY KEY AUTO_INCREMENT,
s_gender CHAR(2) UNIQUE NOT NULL,
s_birthday datetime DEFAULT '1970-01-01',
s_degree VARCHAR(12),
s_graduate_date datetime DEFAULT '1970-01-02',
s_specialty VARCHAR(50),
s_phone VARCHAR(200),
s_salary SMALLINT,
s_allowance DECIMAL(18,2),
s_skill VARCHAR(2000)
);
```
这样就可以成功创建表了。
阅读全文