#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Missing Right Parenthesis all in line 2


    CREATE TABLE LOCATION(
    Locid NUMBER (5) LOCATION_LOCID_PRIMARY KEY,
    Bldg_Code VARCHAR2 (10) NOT NULL,
    Room VARCHAR2 (6) NOT NULL,
    Capacity NUMBER (5));

    CREATE TABLE FALCULTY(
    Fid NUMBER (4) FACULTY_FID_PRIMARY KEY,
    Flname VARCHAR2 (25) NOT NULL,
    Ffname VARCHAR2 (25) NOT NULL,
    Fmi CHAR (1),
    Locid NUMBER (5) NOT NULL,
    Fphone NUMBER (10),
    Frank VARCHAR2(4));

    Create table STUDENT(
    Sid NUMBER (5) STUDENT_SID_PRIMARY KEY,
    Slname VARCHAR2 (25) NOT NULL,
    Sfname VARCHAR2 NOT NULL,
    Smi CHAR (1),
    Saddr VARCHAR2 (30),
    Scity VARCHAR2 (30),
    Sstate CAHR (2) DEFAULT (WI),
    Szip NUMBER (9),
    Sphone NUMBER (10) NOT NULL,
    Sclass CHAR (2) DEFAULT (FR),
    Sdob DATE NOT NULL,
    S_pin NUMBER (4),
    Fid NUMBER (4));
    CREATE TABLE TERM (
    Termid NUMBER (5) TERM_TERMID__PRIMARY KEY,
    Tdesc VARCHAR2 (20) NOT NULL,
    sTATUS VARCHAR2 (20)NOT NULL);

    CREATE TABLE COURSE(
    Cid NUMBER (6) COURSE_CID_PRIMARY KEY,
    Tdesc VARCHAR2 (20) NOT NULL,
    Ccredit NUMBER (2) NOT NULL);

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

    CREATE TABLE ENROLLMENT(
    Sid NUMBER (5) ENROLLMENT_SID_PRIMARY KEY,
    Csecid NUMBER (8) ENROLLMENT_CSECID_PRIMARY KEY,
    Grade CHAR (1));
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    165
    Rep Power
    13
    What is it
    LOCATION_LOCID_PRIMARY KEY
    It is not a definition of Primary Key so what is this?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    I dont know


    Originally Posted by rski
    What is it

    It is not a definition of Primary Key so what is this?
    Honestly this is my first script. From what our lab instructions stated, this is how you defined a primary key. What is the correct definition, or where could I find out how to define the primary key?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    LOCATION_LOCID_PRIMARY KEY
    I think you will find it should be more like:
    LOCATION_LOCID_PK PRIMARY KEY
    You only had PRIMARY as part of the PRIMARY KEY name.
    Personally I never include the PRIMARY KEY constraint in the body of the CREATE TABLE,
    I add it afterwards in an ALTER TABLE statement.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Still did not work


    Originally Posted by clivew
    I think you will find it should be more like:

    You only had PRIMARY as part of the PRIMARY KEY name.
    Personally I never include the PRIMARY KEY constraint in the body of the CREATE TABLE,
    I add it afterwards in an ALTER TABLE statement.
    @clivew I get the same error message.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    Perhaps you can not use a name in this context.
    Try:

    SQL Code:
    CREATE TABLE LOCATION(
    Locid NUMBER (5) PRIMARY KEY,
    ..........

    or

    SQL Code:
    CREATE TABLE LOCATION(
    Locid NUMBER (5) NOT NULL,
    ..........);
     
    ALTER TABLE LOCATION
      ADD CONSTRAINT PK_LOCATION PRIMARY KEY (Locid);


    Clive
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Thanks.


    Originally Posted by clivew
    Perhaps you can not use a name in this context.
    Try:

    SQL Code:
    CREATE TABLE LOCATION(
    Locid NUMBER (5) PRIMARY KEY,
    ..........

    or

    SQL Code:
    CREATE TABLE LOCATION(
    Locid NUMBER (5) NOT NULL,
    ..........);
     
    ALTER TABLE LOCATION
      ADD CONSTRAINT PK_LOCATION PRIMARY KEY (Locid);


    Clive
    I was just about to post. I failed to place both the PK as you stated and the word constraint. The table finally was created.

IMN logo majestic logo threadwatch logo seochat tools logo