473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Mar 28 '07 #1
1 5124
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kenneth Illingsworth | last post by:
I would like to copy the values from each record in the Program table to = another table (tblPrograms). This is the syntax I came up with:=20 select * from Program insert tblPrograms set...
1
by: Wagner | last post by:
Hi, How can I modify table with publication (change of one column length) without completely breaking replication. Thanks in advance
1
by: zaphod | last post by:
I have a form used to populate 2 tables: Provider and Contacts. Provider has a foriegn key column - Contact1ID - which has a foreign key relationship with the prmary key - ID - in the Contacts...
1
by: Good Man | last post by:
Hi there I was just wondering why I should explicitly create a foreign key, especially if i'm not concerned with Cascading/Deleting when a row is changed. For example, let's say I have a...
6
by: Brendan Jurd | last post by:
Hi all, I read on the manual page for Inheritance that: "A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single...
1
by: Jim | last post by:
Hi, I want to add a field to a table in a database that is live and being accessed from the web. I'm using phpMyAdmin and when I try to add the field I get error #1142...
1
by: mankolele | last post by:
I have three tables the customer table and user table and supplier table the customer and supplier have primary key(username) each then the user is supposed to have all the users as foreign...
17
by: Gregor Kovač | last post by:
Hi! Does DB2 handle extended ASCII table? Example: VALUES(CHR(65)) =A VALUES(CHR(129)) =null, but according to www.asciitable.com should be u with umlaut. Any idea ?
2
by: Rahul B | last post by:
Hi. I have created a table CREATE TABLE testschema.player ( country VARCHAR(80) NOT NULL, posn VARCHAR(2) not null ) /
2
by: runway27 | last post by:
i have a field in a table called refid which is varchar defined as NULL. presently every time an insert query is executed i get the lastid and use this to update the refid field in such a way that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.