0

So I am writing this code and it keeps giving me the error: missing right parenthesis. Am I not finding it or something? I have other code that looks like this and worked, but for some reason, this is not wanting to go through. It says it is happening around line 2 of my code....

SQL Code:

CREATE TABLE MOVIES
(title_id NUMBER (10) NOT NULL UNIQUE,
title VARCHAR2 (60) NOT NULL,
description VARCHAR2 (400) NOT NULL,
rating VARCHAR2 (4) CHECK (rating= 'G','PG','PG13','R'),
category VARCHAR2 (20) CHECK (category= 'DRAMA','COMEDY','ACTION','CHILD','SCIFI','DOCUMENTARY'),
release_date NOT NULL),
PRIMARY KEY (title_id));
5
  • This is not MySQL syntax. Trying to convert from another DB engine? Commented Dec 8, 2016 at 6:21
  • Not sure what you are telling me. I am new to all of this. I put this code into ORACLE database to create the table and it's not wanting to create because of a right parenthesis apparently missing. Commented Dec 8, 2016 at 6:24
  • I see. I replaced the MySQL DB tag with Oracle in your question Commented Dec 8, 2016 at 6:25
  • this is typo? right? Commented Dec 8, 2016 at 6:27
  • 2
    Release_date doesn't have field type? Commented Dec 8, 2016 at 6:28

1 Answer 1

1

There are couple of mistakes in your code.

  • unwanted parenthesis after release_date column and a missing datatype
  • For checking list of values you have used = but you need to use IN

Try this

CREATE TABLE MOVIES
  (
     title_id     NUMBER (10) NOT NULL, -- unique key will be overridden by the Primary key 
     title        VARCHAR2 (60) NOT NULL,
     description  VARCHAR2 (400) NOT NULL,
     rating       VARCHAR2 (4) CHECK (rating IN ( 'G', 'PG', 'PG13', 'R')), -- Should be IN instead of = 
     category     VARCHAR2 (20) CHECK (category IN ( 'DRAMA', 'COMEDY', 'ACTION', 'CHILD', 'SCIFI', 'DOCUMENTARY')), -- Should be IN instead of = 
     release_date timestamp NOT NULL, -- Unwanted close parenthesis and missing datatype
     PRIMARY KEY (title_id)
  ); 
Sign up to request clarification or add additional context in comments.

6 Comments

release_date has no type
@igr - yeah missed it
Maybe date or timestamp, datetime is not an Oracle column type
Thanks both of you! Sorry I am new to all of this and surprised I didn't have more mistakes than I did! Thanks again. :)
UNIQUE on title_id is superfluos, as it is covered by primary key
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.