Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to add Foreign key in a table after the creation of the
table?

Answers were Sorted based on User's Feedback



How to add Foreign key in a table after the creation of the table?..

Answer / sagar98

ALTER TABLE <table_name>
ADD CONSTRAINT <fk_name> FOREIGN KEY (column_name)
REFERENCES <table_name_where_this_column_acts_as_PK>
(Column_name)

Is This Answer Correct ?    19 Yes 0 No

How to add Foreign key in a table after the creation of the table?..

Answer / purushotham

we can add a foreign key to a table
1)while creation of table
2)After the creation of the table

by using
Alter table table_name add foreign key(column_name)
References column_name from table_name(that consists of
primary key)

Is This Answer Correct ?    7 Yes 4 No

How to add Foreign key in a table after the creation of the table?..

Answer / devi

alter table table2
add(constraint table2_col2_fk foreign key(col2) references
table1(col1);
here col2 is the foreign key of table2 which refer to the
col1 of table1 which is h epimary key of table1

Is This Answer Correct ?    3 Yes 0 No

How to add Foreign key in a table after the creation of the table?..

Answer / subbu

You cannot add foreign key after creation of the table until
unless you have assigned the primary key while creating the
table. I mean without a primary key assigned for a table, we
cannot add foreign key.

Once the primary key is found, then query to add is been
already given by the above posters.

Is This Answer Correct ?    2 Yes 2 No

How to add Foreign key in a table after the creation of the table?..

Answer / venkatesh

u have create two tables an the time one in first table must an should using primary key .in way of using ddl cmd.
A)alter table table name add fk(clm name) reference column name from table name consists of primary key

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Which normal form is best?

0 Answers  


What are the ways on commenting in a pl/sql code?

0 Answers  


What are the advantages and disadvantages, compared to the standard SQL and SQL*plus ?

2 Answers  


hi sql gurus, here is my question 4 u. i wanna use triggers for sending reminder mail to all users who are registered to the site. if any one knws the code plz send me ans here : chayabs3@gmail.com thnx advance

1 Answers  


Can unique keys be null?

0 Answers  


What is referential integrity ?

3 Answers   BirlaSoft,


Two Methods of retrieving SQL?

7 Answers   Atiric Software, Microsoft, Oracle, TCS, Wipro,


Hi all, I am going to write oracle certification. Can anyone send me the dumps available if any for OCA exam? Its really very urgent, prompt response will help me alot..

8 Answers  


what are wild cards used in database for pattern matching ? : Sql dba

0 Answers  


what is the difference between mysql_fetch_object and mysql_fetch_array? : Sql dba

0 Answers  


How do you retrieve the second highest salary from a table?

3 Answers  


What will you get by the cursor attribute sql%rowcount?

0 Answers  


Categories