1

I have this code, and cannot work out why I am getting issues. Can anyone help? It executes the generate sequence command, but not the create tables one, so I therefore cannot see it on the object browser.

If this helps:

  1. QuizID is to be generated by a sequence.
  2. QuizTitle, is at most 15 characters, and is not null.
  3. Category is to default to Music with Sports and Geography as the only other available options.

SQL code:

CREATE TABLE Quiz_NLB_2 ( QuizID NUMBER, QuizTitle VARCHAR2(15) NOT NULL, Category VARCHAR2(9) DEFAULT 'Music', CONSTRAINT pk_QuizID PRIMARY KEY (QuizID), CONSTRAINT chk_Category CHECK (Category='Music', 'Sports', 'Geography') ); CREATE SEQUENCE QuizID_Sequence_Gen START WITH 100; 

1 Answer 1

1

The check constraint should look like this:

CONSTRAINT chk_Category CHECK (Category IN ('Music', 'Sports', 'Geography')) 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! Really struggled for quite a while, appreciate the help.