使用此定义创建课程表(请尝试使用多行sql语句):
+---------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------------+------+-----+---------+----------------+
| id | int(3) unsigned | NO | PRI | NULL | auto_increment |
| title | varchar(255) | NO | UNI | NULL | |
| credits | tinyint(2) unsigned | NO | | 1 | |
我在尝试创建表时不断遇到错误,这是我的问题:
CREATE TABLE courses
(
id int(3) unsigned NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL UNIQUE,
credits tinyint(2) unsigned NOT NULL DEFAULT 1;
2条答案
按热度按时间ux6nzvsh1#
两个错误:
这个
auto_increment
列必须是mysql中的主键。您需要用一个
)
.此sql有效:
9gm1akwq2#
错误:
Incorrect table definition; there can be only one auto column and it must be defined as a key
正确的sql语句:你的判决失败了
primary key
.