2016-02-29 69 views
0
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行出現語法錯誤。其他一切似乎都沒有錯誤並且不確定。我花了相當長的一段時間搞清楚了。任何建議謝謝。在MySQL中發現未知錯誤

+0

' );'對於所有除第一個創建表語句都缺少''並且刪除最後一列後的逗號 –

+0

Member_ID沒有類型 – robert

+1

一個名爲'member_id'的表?這很奇怪! – Strawberry

回答

0

你忘記添加數據類型一樣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,

,有幾個,);你忘了寫

這似乎工作,我

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) 
); 

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 int not null, 
    Date_Booked date not null 
); 

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

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

create table supplier(
    Supplier_ID int 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 int not null, 
    EquipID int not null, 
    Main_date date not null, 
    Maint_ID int not null, 
    Eng_Name varchar(30), 
    Fault_Desc varchar (200), 
    Maint_Type varchar (7) 
); 
0

有很多錯誤,在此SQL,例如讓我們先表「創建表Member_ID(」及其

  • 第二根弦:
    • Member_ID不爲空 - 你應該添加的類型,例如 INT
    • Member_ID詮釋不爲空 - 現場
  • 7串
    • 地址普通清晰度1 varchar(30),不爲空 - 您應該使用另一個列名稱,地址1,並在varchar(30)之後和之前刪除額外的逗號n ULL
    • 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) 
);