specifying a foreign key by altering a table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zufie

    #1

    specifying a foreign key by altering a table

    Hi,
    I want to specifying a foreign key by altering a table.

    First, I create an ORDERS table without specifying a foreign key. Here
    is my code:

    CREATE TABLE ORDERS
    (Order_ID integer,
    Order_Date date,
    Customer_SID integer,
    Amount double,
    Primary Key (Order_ID));

    Next, I specify a foreign key by altering a table. Here is my code:

    ALTER TABLE ORDERS
    ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);

    What can I do to make this code work with MS Access?

    Thanks for your help!!!!!!!!

    Zufie

  • '69 Camaro

    #2
    Re: specifying a foreign key by altering a table

    Hi, Zufie.
    I want to specifying a foreign key by altering a table.
    Try:

    ALTER TABLE ORDERS
    ADD CONSTRAINT ORDERS_CUSTOMER _FK
    FOREIGN KEY (Customer_SID)
    REFERENCES CUSTOMER (SID);

    HTH.
    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
    Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
    http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
    info.


    "zufie" <john.marruffo@ illinois.govwro te in message
    news:1175096228 .052765.54600@r 56g2000hsd.goog legroups.com...
    Hi,
    I want to specifying a foreign key by altering a table.
    >
    First, I create an ORDERS table without specifying a foreign key. Here
    is my code:
    >
    CREATE TABLE ORDERS
    (Order_ID integer,
    Order_Date date,
    Customer_SID integer,
    Amount double,
    Primary Key (Order_ID));
    >
    Next, I specify a foreign key by altering a table. Here is my code:
    >
    ALTER TABLE ORDERS
    ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);
    >
    What can I do to make this code work with MS Access?
    >
    Thanks for your help!!!!!!!!
    >
    Zufie
    >

    Comment

    Working...