SQL Plus表或视图不存在

时间:2014-12-03 05:17:19

标签: sql oracle

我在第13行(S_dob DATE()行)收到错误'缺少右括号'。在尝试将值插入STUDENT表时,我也收到错误'ORA-00942:表或视图不存在'。

DROP TABLE ENROLLMENT CASCADE CONSTRAINTS PURGE;
DROP TABLE COURSE_SECTION CASCADE CONSTRAINTS PURGE;
DROP TABLE COURSE CASCADE CONSTRAINTS PURGE;
DROP TABLE TERM CASCADE CONSTRAINTS PURGE;
DROP TABLE STUDENT CASCADE CONSTRAINTS PURGE;
DROP TABLE FACULTY CASCADE CONSTRAINTS PURGE;
DROP TABLE LOCATION CASCADE CONSTRAINTS PURGE;

CREATE TABLE ENROLLMENT
(
Sid NUMBER(5) CONSTRAINT PK_ENROLLMENT PRIMARY KEY,
Csecid NUMBER(8),
Grade CHAR(1)
);

INSERT INTO ENROLLMENT
VALUES (100, 1000, 'A');
INSERT INTO ENROLLMENT
VALUES (100, 1003, 'A');
INSERT INTO ENROLLMENT
VALUES (101, 1000, 'C');
INSERT INTO ENROLLMENT
VALUES (102, 1000, 'C');
INSERT INTO ENROLLMENT
VALUES (102, 1001, NULL);
INSERT INTO ENROLLMENT
VALUES (102, 1003, 'I');

CREATE TABLE COURSE_SECTION
(
Csecid NUMBER(8) CONSTRAINT PK_COURSE_SECTION PRIMARY KEY,
Cid NUMBER(6),
Termid NUMBER(5),
Secnum NUMBER(2),
Fid NUMBER(4),
Day VARCHAR2(10),
Locid NUMBER(5),
Maxenrl NUMBER(4),
Currenrl NUMBER(4)
);

INSERT INTO COURSE_SECTION
VALUES (1000, 1, 2, 1, 12, 'MWF', 55, 100, 35);
INSERT INTO COURSE_SECTION
VALUES (1001, 1, 2, 2, 10, 'TTH', 54, 45, 35);

CREATE TABLE COURSE
(
Cid NUMBER(8) CONSTRAINT PK_COURSE PRIMARY KEY,
Callid VARCHAR2(10),
Cname VARCHAR2(30),
Ccredit NUMBER(2)
);

INSERT INTO COURSE
VALUES (1, 'MIS101', 'Intro. to Info. Systems', 3);
INSERT INTO COURSE
VALUES (2, 'MIS321', 'Systems Analysis and Design', 3);
INSERT INTO COURSE
VALUES (3, 'MIS349', 'Intro to Database Management', 3);

CREATE TABLE TERM
(
Termid NUMBER(5) CONSTRAINT PK_TERM PRIMARY KEY,
Tdesc VARCHAR2(20),
Status VARCHAR2(20)
);

INSERT INTO TERM
VALUES (1, 'Spring 2004', 'CLOSED');
INSERT INTO TERM
VALUES (2, 'Summer 2004', 'OPEN');

CREATE TABLE STUDENT
(
Sid NUMBER(5) CONSTRAINT PK_STUDENT PRIMARY KEY,
Slname VARCHAR2(25),
Sfname VARCHAR2(25),
Smi CHAR(1),
Saddr VARCHAR2(30),
Scity VARCHAR2(30),
Sstate CHAR(2),
Szip NUMBER(9),
Sphone NUMBER(10),
Sclass CHAR(2)
Sdob DATE(),
S_pin NUMBER(4),
Fid NUMBER(4)
);

INSERT INTO STUDENT
VALUES (100, 'McClure', 'Sarah', 'M', '144 Windridge Blvd.', 'Eau Claire', 'WI', 54703, 7155559876, 'SR', '14-JUL-1979', 8891, 10);
INSERT INTO STUDENT
VALUES (101, 'Bowie', 'Jim', 'D', '454 St. John Street', 'Eau Claire', 'WI', 54702, 7155552345, 'SR', '19-AUG-1979', 1230, 11);
INSERT INTO STUDENT
VALUES (102, 'Boone', 'Daniel', NULL, '8921 Circle Drive', 'Bloomer', 'WI', 54715, 7155553907, 'JR', '10-OCT-1977', 1613, 11);

CREATE TABLE FACULTY
(
Fid NUMBER(4) CONSTRAINT PK_FACULTY PRIMARY KEY,
Flname VARCHAR2(25),
Ffname VARCHAR2(25),
Fmi CHAR(1),
Fphone NUMBER(10),
F_rank VARCHAR2(4),
F_pin NUMBER(4)
);

INSERT INTO FACULTY
VALUES (10, 'Cox', 'Kim', 'J', 7155551234, 'ASSO', 1181);
INSERT INTO FACULTY
VALUES (11, 'Blanchard', 'Frank', 'R', 7155559087, 'FULL', 1075);
INSERT INTO FACULTY
VALUES (12, 'McClure', 'William', 'L', 7155556409, 'ADJ', 1690);

CREATE TABLE LOCATION
(
Locid NUMBER(5) CONSTRAINT PK_LOCATION PRIMARY KEY,
Bldg_Code VARCHAR2(10),
Room VARCHAR2(6),
Capacity NUMBER(5)
);

INSERT INTO LOCATION
VALUES (53, 'BUS', 424, 45);
INSERT INTO LOCATION
VALUES (54, 'BUS', 404, 35);
INSERT INTO LOCATION
VALUES (55, 'BUS', 433, 100);

Commit;

2 个答案:

答案 0 :(得分:0)

您在创建学生表时错过了逗号

Sphone NUMBER(10),
Sclass CHAR(2)
Sdob DATE(),

替换下面的代码

Sphone NUMBER(10),
Sclass CHAR(2),
Sdob DATE(),

答案 1 :(得分:0)

DATE数据类型后没有括号;替换这个:

Sclass CHAR(2),
Sdob DATE,
S_pin NUMBER(4),

此外,您无法在创建表格之前插入表格!注意create语句中的语法错误,那么你应该很好。