DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Constraints and error messages !!!!!!

  1. #1
    Join Date
    Nov 2001
    Location
    Atlanta GA
    Posts
    45

    Cool Constraints and error messages !!!!!!

    Why won't my query work?

    SQL> create table EMPLOYEE(
    2 ssn char (9) not null,
    3 name varchar2(19) not null,
    4 age number (2),
    5 salary number(8,2),
    6 superssn char(9),
    7 dnumber varchar(8)
    8 constraint EMPLOYEE_ssn_pk primary key (ssn);
    constraint EMPLOYEE_ssn_pk primary key (ssn))
    *
    ERROR at line 8:
    ORA-00907: missing right parenthesis


    SQL> constraint EMPLOYEE_superssn_frk foreign key (superssn)
    SP2-0734: unknown command beginning "constraint..." - rest of line ignored.
    SQL> references employee (ssn);
    SP2-0734: unknown command beginning "references..." - rest of line ignored.
    SQL>
    ===========================================

    Another that may have similar errors, but I cant run until I get
    the other to execute.

    create table DEPARTMENT(
    dnumber varchar(8) not null,
    dname varchar2(15) not null,
    mgrssn char(9),
    mgrstartdate date,
    constraint DEPARTMENT_dnumber_pk primary key (dnumber)
    constraint DEPARTMENT_dname_uk unique (dname)
    constraint DEPARTMENT_mgrssn_fk foreign key (mgrssn)
    references employee (ssn));
    Why won't my query work?

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253

    Re: Constraints and error messages !!!!!!

    You are missing closing parenthesis at the end of the statement, anda comma at the end of line 7.
    Code:
    create table EMPLOYEE(
     ssn char (9) not null,
     name varchar2(19) not null,
     age number (2),
     salary number(8,2),
     superssn char(9),
     dnumber varchar(8),
     constraint EMPLOYEE_ssn_pk primary key (ssn))
    You are also making a design error by implementing SSN as the primary key -- not only do people's SSN's occasionally change (due to identify theft, for example), but you are making it more difficult to hide the SSN from unauthorized access because you now need to scatter it as a foreign key throughout your schema.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width