简体   繁体   English

Oracle 12c将列添加到表中而没有默认值会花费很长时间

[英]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 我正在尝试在测试的Oracle 12c R2环境中向现有约30,000行的表中添加新列,但是该列已经运行了一个多小时,并且完全锁定了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. 我没有指定任何默认值,因为不需要一个默认值,默认情况下应为NULL。

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 在运行Alter Table语句之前,我还临时禁用了该表上的所有触发器

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. 汤姆·凯特(Tom Kyte)在上面的链接中提供了完整的解释。 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. 而且,您可以完全控制数据的迁移方式,因此不会陷入麻烦,但是对于30,000行表而言,锁很可能使CPU旋转。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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