T_1
--------------
NAME VARCHAR2(100) not null (primary key)
AGE INT
ID VARCHAR2(100)
PASS VARCHAR
NAME is the primary key.
If we want to add INT to the primary key and make it a composite key:
1. We must first make the ID column "not null" which means it could not have any NULL entries.
2. We should drop the existing primary key.
3. Create the new primary key.
PL/SQL script to achive this:
alter table T_1 modify NAME VARCHAR2(100) NOT NULL;
alter table T_1 drop primary key;
alter table T_1 add primary key (NAME, ID);
commit;
:)
No comments:
Post a Comment