1 Replies - 1236 Views - Last Post: 17 December 2015 - 04:12 PM

#1 kyle01   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 202
  • Joined: 26-November 14

Creating a Table in Oracle

Posted 17 December 2015 - 02:25 PM

I have produced this code for oracle but I have a question, I've tried adding a foreign key from a existing table but it doesn't work, I don't want to try run the code again in case it messes anything up, but my question is; what syntax or code would i add to my Bookings table code below to add a foreign key

Booking_ID_Number VARCHAR2(10) NOT NULL,
Trip_Details VARCHAR2(120) NOT NULL,
Date_Required DATE NOT NULL,
PRIMARY KEY (Booking_ID_Number),

Customer_ID VARCHAR2(10) NOT NULL,
Contact_Name VARCHAR2(60) NOT NULL,

^ Would i add the foreign key like this, or is there a more correct way of going about it, thanks for any answers.

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a Table in Oracle

#2 baavgai   User is offline

  • Dreaming Coder
  • member icon

Reputation: 7198
  • View blog
  • Posts: 15,006
  • Joined: 16-October 07

Re: Creating a Table in Oracle

Posted 17 December 2015 - 04:12 PM

For a foreign key you also need the foreign entity you're associating it with.

Keys are a form of constraint are can be create with more standard with constraint syntax. Though Oracle offers some helpful shorthand. More here: http://www.orafaq.com/wiki/Foreign_key
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1