Results 1 to 8 of 8

Thread: SQL command

  1. #1
    Join Date
    Jul 2012
    Posts
    5

    Unanswered: SQL command

    how to write below command in correct way

    create table Crew
    (CrewNo varchar2(10) constraint CrewPK primary key,
    FlightNo varchar2(10),
    FlightDate date,
    Hours number(4),
    constraint CrewFK1 foreign key FlightNo references Flight(FlightNo) not null,
    constraint CrewFK1 foreign key FlightDate references Flight(FlightDate) not null);


    FlightNo and FlightDate are both primary key in table Flight.

  2. #2
    Join Date
    Jul 2012
    Posts
    5
    the error is
    Error at Command Line:6 Column:31
    Error report:
    SQL Error: ORA-00906: missing left parenthesis

  3. #3
    Join Date
    Jul 2012
    Posts
    5
    anyone can help?

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Code:
    CREATE TABLE crew 
      ( 
         crewno     VARCHAR2(10) CONSTRAINT crewpk PRIMARY KEY, 
         flightno   VARCHAR2(10), 
         flightdate DATE, 
         hours      NUMBER(4), 
         CONSTRAINT crewfk1 FOREIGN KEY (flightno) REFERENCES flight(flightno), 
         CONSTRAINT crewfk1 FOREIGN KEY (flightdate) REFERENCES flight(flightdate) 
      );
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jul 2012
    Posts
    5
    SQL Error: ORA-02270: no matching unique or primary key for this column-list
    02270. 00000 - "no matching unique or primary key for this column-list"
    *Cause: A REFERENCES clause in a CREATE/ALTER TABLE statement
    gives a column-list for which there is no matching unique or primary
    key constraint in the referenced table.

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >FlightNo and FlightDate are both primary key in table Flight.
    Is above or below true?
    >SQL Error: ORA-02270: no matching unique or primary key for this column-list
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Jul 2012
    Posts
    5
    FlightNo and FlightDate are both primary key in table Flight is true,
    but still get this error message.

  8. #8
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Code:
    CREATE TABLE crew 
      ( 
         crewno     VARCHAR2(10) CONSTRAINT crewpk PRIMARY KEY, 
         flightno   VARCHAR2(10), 
         flightdate DATE, 
         hours      NUMBER(4), 
         CONSTRAINT crewfk1 FOREIGN KEY (flightno,flightdate) REFERENCES flight(flightno,flightdate)
     );
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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