这是我在tera术语中执行的文本文件。
DROP TABLE purchase; CREATE TABLE purchase
( ID NUMBER(4) NOT NULL,
Fname VARCHAR2(10),
Lname VARCHAR2(10),
Vin NUMBER(10),
Email VARCHAR(10),
unit NUMBER(10),
Street VARCHAR2(50),
Suburb VARCHAR2(50),
Pcode NUMBER(4),
credit VARCHAR2(20),
holder VARCHAR2(20),
Expiry NUMBER(4)
Primary key (ID)
); commit;
我收到了错误
DROP TABLE purchase
*
ERROR at line 1:
ORA-00942: table or view does not exist
Primary key (ID)
*
ERROR at line 14:
ORA-00907: missing right parenthesis
答案 0 :(得分:0)
使用此
DROP TABLE purchase;
CREATE TABLE purchase
( ID NUMBER(4) NOT NULL,
Fname VARCHAR2(10),
Lname VARCHAR2(10),
Vin NUMBER(10),
Email VARCHAR(10),
unit NUMBER(10),
Street VARCHAR2(50),
Suburb VARCHAR2(50),
Pcode NUMBER(4),
credit VARCHAR2(20),
holder VARCHAR2(20),
Expiry NUMBER(4),
CONSTRAINT purchase_pk PRIMARY KEY (ID)
);
BEWARE 关于purchase
不存在的第一个错误(ORA-00942)没问题......第一次运行时会发生这种情况。
答案 1 :(得分:0)
或者这个:
DROP TABLE purchase;
CREATE TABLE purchase
( ID NUMBER(4) PRIMARY KEY,
Fname VARCHAR2(10),
Lname VARCHAR2(10),
Vin NUMBER(10),
Email VARCHAR(10),
unit NUMBER(10),
Street VARCHAR2(50),
Suburb VARCHAR2(50),
Pcode NUMBER(4),
credit VARCHAR2(20),
holder VARCHAR2(20),
Expiry NUMBER(4)
);
将主键约束应用于列意味着“唯一”和“非空”约束。