473,662 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5150
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.govwro te in message
news:11******** *************@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

Mar 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1259
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 ProgramCode=3DLocation, = ProgramName=3DDescription; However, it fails without telling me why. Perhaps someone could correct me = or re-direct me on this issue? Thank you.
1
1233
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
2109
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 table. The form submits data to Contacts then Provider but I need the ID generated by the Contacts submission to be entered into the Contact1ID column in the Provider table. If I use this: INSERT INTO Provider(Contact1ID) SELECT ID FROM Contacts
1
1490
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 USERS table, with the column 'USERID' as a primary key. Other columns would be 'NAME' and 'EMAIL'. In my users table I have two rows: and
6
2794
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 tables, not to their inheritance children. Thus, in the above example, specifying that another table's column REFERENCES cities(name) would allow the other table to contain city names but not capital names. This deficiency will probably be fixed...
1
4078
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 (ER_TABLEACCESS_DENIED_ERROR) "ALTER command denied to user 'xxx' for table 'yyy'" I'm a newbie to MySQL but I guess that's a reasonable error as there are probably open connections. If that is the reason, is there a way I can force all connections to close and not...
1
4808
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 key(username) from both tables which I need to use it to be able to differentiate when logging in but i dont know how to fill a customer form then the other info must go to the user table where there is a foreign key. I can only fill from a form the...
17
11786
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
5711
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
1032
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 this field records information like E1 E2 E3..... as per the code below. --------------------------------------------------------------- $lastid = mysql_insert_id(); UPDATE tablename SET refid = 'E$lastid' WHERE ref = '$lastid'...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.