Composite primary key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nasiya
    New Member
    • Mar 2008
    • 2

    #1

    Composite primary key

    Hi sir,

    How to refer the combination primary field in another table.

    ie,I have 2 tables emp and empl,
    [create table emp(e_no varchar2(10),o_ no varchar2(10),e_ name(varchar2(1 0),primary key(e_no,o_no)) ;]

    I want to refer only this e_no into another table empl.
    if it is not possible ie only refer e_no.
    How can refer both these fields.
    How can do this.Give the tips and if my emp table query is not correct pls mention where iam made mistake.
  • Nasiya
    New Member
    • Mar 2008
    • 2

    #2
    Originally posted by Nasiya
    Hi sir,

    How to refer the combination primary field in another table.

    ie,I have 2 tables emp and empl,
    [create table emp(e_no varchar2(10),o_ no varchar2(10),e_ name(varchar2(1 0),primary key(e_no,o_no)) ;]

    I want to refer only this e_no into another table empl.
    if it is not possible ie only refer e_no.
    How can refer both these fields.
    How can do this.Give the tips and if my emp table query is not correct pls mention where iam made mistake.
    create table empl(e_no varchar2(10)ref erences emp(e_no))

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Try this:

      [code=oracle]

      create table emp (e_no varchar2(10),o_ no varchar2(10),pr imary key(e_no,o_no))

      create table empl(e_no varchar2(10), o_no varchar2(10),fo reign key(e_no,o_no) references emp(e_no,o_no))

      [/code]

      Comment

      Working...