Reputation: 750
What is the statement to alter a table which holds about 10 million rows, adding a guid
column which will hold a unique identifier for each row (without being part of the pk)
What datatype should the global unique identifier column be? Is there a procedure which creates it? How will it auto incremented or produced everytime a new record is inserted?
Upvotes: 0
Views: 2286
Reputation: 56
Another way to avoid creating constraints, indexes present on original table onto the new table is to create an empty table with all constraints, indexes and identity column. Let DBA extract data from the original table and import it into the "new" table.
Benefits: This approach will ensure that none of the objects dependent on the source table become INVALID which generally hampers some features of the application(s).
Upvotes: 1
Reputation: 11195
Break it down into the separate stages
First, we need a new column:
alter table MyTable
add guid_column raw(32) default sys_guid();
Then update the existing rows:
update MyTable
set guid_column = sys_guid();
Upvotes: 2