If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > alter table.. foreign key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-03, 12:21
trilly trilly is offline
Registered User
 
Join Date: Aug 2003
Location: Vicenza(I)
Posts: 21
Question alter table.. foreign key

I want to add a foreign key codnegozio references to negozio.idnegozio on table cliente
The table cliente is:
CREATE TABLE Cliente
(User_id VARCHAR(10)PRIMARY KEY ,
Nome VARCHAR2(15) NOT NULL ,
Cognome VARCHAR2(15) NOT NULL,
Indirizzo VARCHAR2(50) NOT NULL ,
CAP NUMBER(6) NOT NULL,
Cittą VARCHAR2(50) NOT NULL ,
Provincia VARCHAR2(50) NOT NULL,
Password VARCHAR2(8) NOT NULL ,
Email VARCHAR2(100) NOT NULL,
Credito NUMBER(6) NOT NULL,
Carta_credito NUMBER(10))

and the table negozio is:
CREATE TABLE Negozio
(IdNegozio NUMBER(8) PRIMARY KEY auto-increment,
Ragione_Sociale VARCHAR2(20) NOT NULL,
Indirizzo VARCHAR2(15) NOT NULL ,
CAP NUMBER(6) NOT NULL,
Cittą VARCHAR2(15) NOT NULL ,
Provincia VARCHAR2(15) NOT NULL,
Email VARCHAR2(15) NOT NULL)

what' s can I do?
Thank you Elisa
__________________
Elisa Pinton
Reply With Quote
  #2 (permalink)  
Old 09-16-03, 12:59
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: alter table.. foreign key

Is this Oracle? If so:

alter table Cliente add (codnegozio NUMBER(8));

alter table Cliente add constraint my_constraint_name foreign key (codnegozio) references Negozio;
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On