简体   繁体   中英

Oracle 12c Adding Column to table without default value taking really long

I'm trying to add a new column to an existing table of approximately 30,000 rows in our test Oracle 12c R2 environment, but it has been running for over an hour and completely locked up SQL Developer

Here is the basic syntax that I used. I didn't specify any default value since one isn't needed and should be NULL by default.

ALTER TABLE "Schema"."Table" ADD "C_C6" VARCHAR2(8 BYTE)

I tried looking up this issue, but most cases seem to refer to issues where people are trying to specify default values, which I'm not doing.

I have also temporarily disable any triggers that I had on the table prior to running the Alter Table statement

Any suggestions?

Sounds like you want Edition-Based Redefinition that allows you to create a new edition of the database, create a view of the table in the old edition, rename the table in the old edition, and in the new edition add the column to the renamed table, and then migrate the data from the old edition to the new edition. Tom Kyte gives a full explanation at the link above. The only downtime will be a few minutes to rename the table in the old edition. And you have full control over how you migrated the data so you won't bog things down, but for a 30,000 row table it is just likely the locks were spinning the CPU.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM