Please help me how to write a Query to change the primary
key constraint from 1 attribute to another attribute in a
table

Answer Posted / dinesh a.

You can assing only one primary key on a table , so you
can't modify directoly one column to another , you need to
drop first one then create on another attribute.

SQL>ct constraint_name,constraint_type from user_constraints
where table_name='EMP' and constraint_type='P';

CONSTRAINT_NAME C
------------------------------ -
SYS_C00125220 P

SQL> alter table emp drop constraint SYS_C00125220;

sql> alter table any_table add constraint my_cons_nm
primary key(column_of_tab)

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List out the difference between commit, rollback, and savepoint?

632


How to add another datafile to a tablespace?

588


How to load excel data sheet to oracle database

598


Can we create trigger on materialized view in oracle?

579


how to do daily transactions with out sql* loader control file regesterd in apps?

1228






what is the difference between substr and instr function in oracle?

595


What is a trace file and how is it created in oracle?

560


What is ASM (Automatic Storage Management) in Oracle?

719


Explain database link?

678


What is the difference between translate and replace in oracle?

669


How to convert characters to numbers in oracle?

602


What is a lookup table in oracle?

555


Why do I get unexpected characters from 8-bit character sets in weblogic jdriver for oracle?

620


What operating systems are supported by oracle database 10g xe?

593


What are dml statements in oracle?

633