Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Location
    Vicenza(I)
    Posts
    21

    Question Unanswered: 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

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •