By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

specifying a foreign key by altering a table

P: n/a
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

Mar 28 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <jo***********@illinois.govwrote in message
news:11*********************@r56g2000hsd.googlegro ups.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

Mar 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.