请帮我解决这个错误,试着在mysql中创建数据库

时间:2018-06-16 19:03:35

标签: java mysql jdbc netbeans connector

我在mysql上得到了这个错误"你的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在'""" Staff_information" (" id" INTEGER PRIMARY KEY," first_name" VARCHAR,"姓氏"'在第5行"

CREATE TABLE" Staff_information" (" id" INTEGER PRIMARY KEY," first_name" VARCHAR," surname" VARCHAR,                                   "多波" INTEGER DEFAULT(null),                                   "电子邮件" VARCHAR,"电话" VARCHAR,"地址" VARCHAR,"系" VARCHAR,                                   "图像" BLOB,"性别" CHAR,                                   "薪酬和#34; VARCHAR,"地址2" VARCHAR,"公寓" VARCHAR," Post_code" VARCHAR DEFAULT(null),                                   "指定" VARCHAR,"状态" VARCHAR," Date_hired" VARCHAR," JOB_TITLE" VARCHAR)

2 个答案:

答案 0 :(得分:1)

您的查询有几个问题。

  • 您不应在创建表格查询
  • 中使用" - 符号
  • 您可以省略DEFAULT(null),因为null已经是默认设置
  • 您必须将字符数量添加到VARCHARCHAR列,例如VARCHAR(255)

所以你的陈述应该是这样的:

CREATE TABLE Staff_information 
(id INTEGER PRIMARY KEY, first_name VARCHAR(255), surname VARCHAR(255), Dob INTEGER, 
Email VARCHAR(255), Telephone VARCHAR(255), Address VARCHAR(255), Department VARCHAR, 
Image BLOB, Gender CHAR(50), Salary VARCHAR(255), Address2 VARCHAR(255), Apartment 
VARCHAR(255), Post_code VARCHAR(255), Designation VARCHAR(255), Status VARCHAR(255), 
Date_hired VARCHAR(255), job_title VARCHAR(255));

答案 1 :(得分:1)

如果这是MySQL,您使用的数据类型应该是INT,而不是整数。