1

だから、これは私のコードです。学校が提供するエンジンでコンパイルしようとすると、いくつかのエラーが発生し、実行するたびにエラーが変化しますが、現在持っているものは次のとおりです。

123 行目のエラー 1064 (42000): SQL 構文にエラーがあります。Near '9:30, 'L210', 103, 15), (86, 25, 2, 6/10/2007 9:30, 'L210' , 107, 15), (2 行目の 89, 25, 5'

すでにスペースを取り出そうとしましたが、違いはありません。これは、私が情報を取得する順序と関係がありますか? それとも別のものですか?

また、ステップ 1 でテーブルがドロップされているかどうかもわかりません。

/*Step One: Drop Tables*/
DROP TABLE IF EXISTS Student;
DROP TABLE IF EXISTS Zipcode;
DROP TABLE IF EXISTS Instructor;
DROP TABLE IF EXISTS Enrollment;
DROP TABLE IF EXISTS Sections;
DROP TABLE IF EXISTS Course;


/*Step Two: Create Tables*/
CREATE TABLE Zipcode
(
zip             int(11), 
city            varchar(25)     NOT NULL,  
state           varchar(2)      NOT NULL,
PRIMARY KEY (zip)
);

CREATE TABLE Student
(
student_ID          int(6)          UNIQUE,
salutation          varchar(5), 
first_name          varchar(25)     NOT NULL, 
last_name           varchar(25)     NOT NULL, 
street_address      varchar(50), 
phone               int(15)         NOT NULL, 
employer            varchar(50) , 
registration_date   date            NOT NULL, 
zip                 int(11),
PRIMARY KEY (student_ID),
FOREIGN KEY (zip) REFERENCES Zipcode (zip)
);

CREATE TABLE Course
(
    course_ID           int(6)          UNIQUE,
    description         varchar(50)     NOT NULL,
    cost                dec(8,2)        NOT NULL,
    prerequisite        int(6),
    PRIMARY KEY (course_ID),
    FOREIGN KEY (prerequisite) REFERENCES Course (course_ID)
);

CREATE TABLE Instructor
(
Instructor_ID   int(6)              UNIQUE,
salutation      varchar(5), 
first_name      varchar(25)         NOT NULL, 
last_name       varchar(25)         NOT NULL, 
street_address  varchar(50), 
zip             int(11)             NOT NULL,
PRIMARY KEY (Instructor_ID),
FOREIGN KEY (zip) REFERENCES zipcode (zip)
);

CREATE TABLE Sections
(
section_ID          int(8)          UNIQUE,
course_id           int(6)          NOT NULL,
course_section_num  int(6)          NOT NULL,
start_date_time     datetime        NOT NULL,
location            varchar(10),
instructor_ID       int(6)          NOT NULL,
capacity            int(3),
PRIMARY KEY (section_ID),
FOREIGN KEY (instructor_ID) REFERENCES Instructor (instructor_ID),
FOREIGN KEY (course_ID) REFERENCES Course (course_ID)   
);

CREATE TABLE Enrollment
(
student_ID          int(6)          UNIQUE,
section_ID          int(8)          UNIQUE,
enroll_date         datetime        NOT NULL,
final_grade         char(1),
PRIMARY KEY (section_ID, student_ID),
FOREIGN KEY (section_ID) REFERENCES sections (section_ID),
FOREIGN KEY (student_ID) REFERENCES student (student_ID)
);


/*Step Three: Insert Rows*/
INSERT INTO Zipcode VALUES
(7024, 'Ft. Lee', 'NJ'),
(7047, 'North Bergen', 'NJ'),
(10005, 'New York', 'NY'),
(10015, 'New York', 'NY'),
(10025, 'New York', 'NY'),
(10035, 'New York', 'NY'),
(11419, 'Richmond Hill', 'NY'),
(11435, 'Jamaica', 'NY');

INSERT INTO Student VALUES
(102, 'Mr.', 'Fred', 'Crocitto', '101-09 120th St.', 718-555-5555, 'Albert Hildegard Co.', 1/22/2007, 11419),
(103, 'Ms.', 'J.', 'Landry', '7435 Boulevard East #45', 201-555-5555, 'Albert Hildegard Co.', 1/22/2007, 7047),
(104, 'Ms.', 'Laetia', 'Enison', '144-61 87th Ave', 718-555-5555, 'Albert Hildegard Co.', 1/22/2007, 11435),
(105, 'Mr.', 'Angel', 'Moskowitz', '320 John St.', 201-555-5555, 'Alex. & Alexander', 1/22/2007, 7024),
(163, 'Ms.', 'Nicole', 'Gillen', '4301 N Ocean #103', 904-555-5555, 'Oil of America Corp.', 2/2/2007, 10025),
(223, 'Mr.', 'Frank', 'Pace', '13 Burlington Dr.', 203-555-5555, 'Board Utilities', 2/8/2007, 10025),
(399, 'Mr.', 'Jerry', 'Abdou', '460 15th St. #4', 718-555-5555, 'Health Mgmt.Systems', 2/23/2007, 10025);

INSERT INTO Course VALUES
(330, 'Network Administration', 1195, 130),
(310, 'Operating Systems', 1195, NULL),
(142, 'Project Management', 1195, 20),
(140, 'Systems Analysis', 1195, 20),
(130, 'Intro to Unix', 1195, 310),
(25, 'Intro to Programming', 1195, 140),
(20, 'Intro to Information Systems', 1195, NULL);

INSERT INTO Instructor VALUES
(101, 'Mr.', 'Fernand', 'Hanks', '100 East 87th', 10015),
(102, 'Mr.', 'Tom', 'Wojick', '518 West 120th', 10025),
(103, 'Ms.', 'Nina', 'Schorin', '210 West 101st', 10025),
(104, 'Mr.', 'Gary', 'Pertez', '34 Sixth Ave', 10035),
(105, 'Ms.', 'Anita', 'Morris', '34 Maiden Lane', 10015),
(106, 'Rev.', 'Todd', 'Smythe', '210 West 101st', 10025),
(107, 'Dr.', 'Marilyn', 'Frantzen', '254 Bleeker', 10005);

INSERT INTO Sections VALUES
(81, 20, 2, 7/24/2007 9:30, 'L210', 103, 15),
(86, 25, 2, 6/10/2007 9:30, 'L210', 107, 15),
(89, 25, 5, 5/15/2007 9:30, 'L509', 103, 25),
(92, 25, 8, 6/13/2007 9:30, 'L509', 106, 25),
(104, 330, 1, 7/14/2007 10:30, 'L511', 104, 25),
(119, 142, 1, 7/14/2007 9:30, 'L211', 103, 25),
(155, 122, 4, 5/4/2007 9:30,  'L210', 107, 15);

INSERT INTO Enrollment VALUES
(102, 86, 1/30/2007, NULL, 'B'),
(102, 89, 1/30/2007, 92,'A'),
(103, 81, 1/30/2007, NULL),
(104, 81, 1/30/2007, NULL, 'A'),
(163, 92, 2/10/2007, NULL),
(223, 104, 2/16/2007, NULL,'C'),
(223, 119, 2/16/2007, NULL);


/*Step Four: Select Statements*/
SELECT * FROM Student;
SELECT * FROM Zipcode;
SELECT * FROM Instructor;
SELECT * FROM Course;
SELECT * FROM Sections;
SELECT * FROM Enrollment;
4

1 に答える 1