私はデータベースにまったく慣れておらず、Oracleの構文に多少の混乱があります。それに付随する整合性制約のあるテーブルを作成しようとしています。
これが私のコードです:
CREATE TABLE Students
(
id INTEGER,
name CHAR(10) NOT NULL,
classification CHAR(10) NOT NULL,
hours INTEGER,
gpa NUMBER(3,2) NOT NULL,
mentor INTEGER,
CONSTRAINT IC1 CHECK (PRIMARY KEY (id))
CONSTRAINT IC2 CHECK (classification = 'freshman' or classification = 'sophomore' or classification = 'junior' or classification = 'senior')
CONSTRAINT IC3 CHECK (gpa >= 0 AND gpa <= 4)
CONSTRAINT IC4 CHECK (classification = 'junior' AND hours >= 55 AND hours <= 84) );
ただし、コードを実行すると、次のようになります。
SQL> CONSTRAINT IC1 CHECK (PRIMARY KEY (id))
SP2-0734: unknown command beginning "CONSTRAINT..." - rest of line ignored.
SQL> CONSTRAINT IC2 CHECK (classification = 'freshman' or classification = 'sophomore' or classification = 'junior' or classification = 'senior')
SP2-0734: unknown command beginning "CONSTRAINT..." - rest of line ignored.
SQL> CONSTRAINT IC3 CHECK (gpa >= 0 AND gpa <= 4)
SP2-0734: unknown command beginning "CONSTRAINT..." - rest of line ignored.
SQL> CONSTRAINT IC4 CHECK (classification = 'junior' AND hours >= 55 AND hours <= 84) );
SP2-0734: unknown command beginning "CONSTRAINT..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
誰かが私の制約構文を手伝ってくれますか?