如何制作数据库表?

时间:2018-11-21 05:51:09

标签: mysql database

我想做JDBC,所以我尝试enter image description here

mysql> use video_db;
Database changed
mysql> create table videos(
    -> code varchar(10) not null,
    -> title varchar(30),
    -> ganre varchar(30),
    -> releaseDay varchar(10),
    -> isRental char(1),
    -> rentalPrice int(11),
    -> primarykey(code)
    -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(code)
)' at line 8

我该如何解决?请帮我

1 个答案:

答案 0 :(得分:0)

您在“主键”和“键”之间缺少空格:

mysql> create table videos(
    -> code varchar(10) not null,
    -> title varchar(30),
    -> ganre varchar(30),
    -> releaseDay varchar(10),
    -> isRental char(1),
    -> rentalPrice int(11),
    -> primary key(code) -- Here!
    -> );