-
hi friends,
after creating a table with no constraints and then loading data into it, can we then define a primary key to that table ?
thanks
-
Sure,
ALTER TABLE xyz ADD CONSTRAINT pk_xyz PRIMARY KEY (pk_field);
Jeff Hunter
-
Better :
ALTER TABLE xyz ADD CONSTRAINT pk_xyz PRIMARY KEY (pk_field)
using index
tablespace ...
pctfree XX
storage (...)
exception into .....;
because you loaded data into table and nobody never sure that PK column is primary key.
-
thanks , the primary key worked, but, after creating a table and if i have to make a column not null, which already has data in it what do i do?
-
Simply alter the table.
ALTER TABLE my_table MODIFY (my_column NOT NULL);
If there is any NULL value in MY_COLUMN the above will fail. You will first need to set all rows to have non-null value in that column, then you add NOT NULL constraint.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|