在MySQL中获取未知错误

时间:2016-02-29 11:43:39

标签: mysql sql

create table Member_ID(
Member_ID not null,
Title varchar(4) not null,
Forename varchar(30) not null,
Surname varchar(30) not null,
DOB date not null,
Address 1 varchar (30), not null,
Address 2 varchar (30), not null,
Postcode varchar(8), not null,
MobileNo char (11), not null,
Email varchar (30), not null,
Gender char (1), not null,
Medical varchar (30), not null,
Joining_Date date not null,
Paid varchar (4), not null,
Membership_Type char(1), not null,
Staff_Initials char (2), not null,



Primary key (Member_ID) );

create table class(
Class_Name varchar (30) not null, 
ClassDayofWeek date not null,
Class_Time select get date not null,
Class_Duration char(4) not null,
Studio_ID char (4) not null,
Instructor_ID int not null,


create table class_list(
Class_ID varchar (30) not null,
Member_ID not null,
Date_Booked date not null,

create table Instructor(
Instructor_ID not null,
InsFirstName varchar (30) not null,
InsSurname varchar (30) not null,
InsContactNo char (11) not null,

create table Equipment(
Equip_ID not null,
Supplier_ID not null,
Studio_ID not null,
Equip_Name varchar (30),

create table supplier(
Supplier_ID not null,
Supplier_Name varchar (30) not null,
SupplierContactNo char (11) not null,
Supplier_Email varchar (30) not null,

create table Equipment_Maintanence(
Maintenence_ID not null,
EquipID not null,
Main_date date not null
Maint_ID not null,
Eng_Name varchar (30)
Fault_Desc varchar (200)
Maint_Type varchar (7)

您好, 我试图在MySQL中创建一个表并且是初学者所以请耐心等待。我在第2,7,26,32行遇到语法错误。其他所有内容似乎都没有错误且不确定。我花了很长时间搞清楚。任何建议谢谢。

2 个答案:

答案 0 :(得分:0)

你忘了添加很多列的数据类型,例如WHERE `active` = 0 OR ... 它应该是Member_ID not null

如果列名有空格,你应该就是那个

Member_ID int not null

`Address 1` varchar(30) not null

另外Address 1 varchar(30) not null 这里还有Postcode varchar(8), not null,,

并且很少Postcode varchar(8) not null,,您忘了写

这似乎对我有用

);

答案 1 :(得分:0)

这个sql中有很多错误,例如让我们得到第一个表“create table Member_ID(”及其

  • 第二串:
    • Member_ID不为null - 例如,您应该添加类型 int
    • Member_ID int not null - 字段的正常定义
  • 第7个字符串
    • 地址1 varchar(30),非空, - 您应该使用另一个列名,f.e地址1并删除varchar(30)之后和非空之前的额外逗号
    • Address_1 varchar(30)not null - 字段的正常定义

所以我修复了整个第一张表并获得了这段代码:

create table Member_ID(
    Member_ID int not null,
    Title varchar(4) not null,
    Forename varchar (30) not null,
    Surname varchar (30) not null,
    DOB date not null,
    Address_1 varchar(30) not null,
    Address_2 varchar(30) not null,
    Postcode varchar(8) not null,
    MobileNo char(11) not null,
    Email varchar(30) not null,
    Gender char(1) not null,
    Medical varchar(30) not null,
    Joining_Date date not null,
    Paid varchar(4) not null,
    Membership_Type char(1) not null,
    Staff_Initials char(2) not null,
    Primary key (Member_ID)
);