oracle 11G 新增欄位調整效能
要在公司的測試庫新增二個pflag,pflag2欄位,表的資料量為590W 。
按照以前的方式alter table ehr_healthrecord add (pflag numer default (0));
花費時間為16:15min
alter table hzwsj.EHR_HEALTHRECORD add (pflag2 number default(0) not null);
花費時間為407msecs 毫秒!!! 天壤之別!!!
反向把pflag2 設定為null 花時間為15:28 秒 突突。。。。。alter table hzwsj.EHR_HEALTHRECORD modify pflag2 null;
ORACLE 裡面有一段介紹
Adding Table Columns
To add a column to an existing table, use the ALTER TABLE...ADD statement.
The following statement alters the hr.admin_emp table to add a new column named bonus:
ALTER TABLE hr.admin_emp
ADD (bonus NUMBER (7,2));
If a new column is added to a table, the column is initially NULL unless you specify the DEFAULT clause. When you specify a default value, the database immediately updates each row with the default value. Note that this can take some time, and that during the update, there is an exclusive DML lock on the table. For some types of tables (for example, tables without LOB columns), if you specify both a NOT NULL constraint and a default value, the database can optimize the column add operation and greatly reduce the amount of time that the table is locked for DML.
如果要在一張已經存在的表中新增一個欄位,你沒有指定預設值的話他預設為NULL,當你指定了預設值的時候資料庫直接在每行上直接更新新增的值,這需要花上一段時間,並且會在這段時間內產生DML 鎖。對於一些型別表(例如沒有lob欄位的表) 如果你新增的欄位是not null 的並且有一個預設的初始值,資料庫能夠對新增列進行優化,減少大量資料庫被DML鎖的時間。
You can add a column with a NOT NULL constraint only if the table does not contain any rows, or you specify a default value.
alter table hzwsj.EHR_HEALTHRECORD add (pflag2 number default(0) not null);
花費時間為407msecs 毫秒!!! 天壤之別!!!
反向把pflag2 設定為null 花時間為15:28 秒 突突。。。。。alter table hzwsj.EHR_HEALTHRECORD modify pflag2 null;
ORACLE 裡面有一段介紹
Adding Table Columns
To add a column to an existing table, use the ALTER TABLE...ADD statement.
The following statement alters the hr.admin_emp table to add a new column named bonus:
ALTER TABLE hr.admin_emp
ADD (bonus NUMBER (7,2));
If a new column is added to a table, the column is initially NULL unless you specify the DEFAULT clause. When you specify a default value, the database immediately updates each row with the default value. Note that this can take some time, and that during the update, there is an exclusive DML lock on the table. For some types of tables (for example, tables without LOB columns), if you specify both a NOT NULL constraint and a default value, the database can optimize the column add operation and greatly reduce the amount of time that the table is locked for DML.
如果要在一張已經存在的表中新增一個欄位,你沒有指定預設值的話他預設為NULL,當你指定了預設值的時候資料庫直接在每行上直接更新新增的值,這需要花上一段時間,並且會在這段時間內產生DML 鎖。對於一些型別表(例如沒有lob欄位的表) 如果你新增的欄位是not null 的並且有一個預設的初始值,資料庫能夠對新增列進行優化,減少大量資料庫被DML鎖的時間。
You can add a column with a NOT NULL constraint only if the table does not contain any rows, or you specify a default value.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26764973/viewspace-1458695/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle-欄位的新增Oracle
- Oracle 增加修改刪除欄位與新增註釋Oracle
- Oracle-新增一個欄位並設定日期Oracle
- fastadmin 新增欄位記圖片欄位AST
- Oracle Tuning (Oracle 效能調整)的一些總結(轉)Oracle
- Oracle Tuning (Oracle 效能調整)的一些總結(轉)2Oracle
- oracle中判斷欄位是否存在和新增表結構Oracle
- Oracle 11g RAC手動新增serviceOracle
- orcle效能調整(轉)
- Oracle 11g RAC重新新增節點Oracle
- oracle 線上調整redoOracle
- win10如何調整開始欄大小_win10開始欄怎麼調整Win10
- MySQL欄位新增註釋,但不改變欄位的型別MySql型別
- ORACLE LOB大欄位維護Oracle
- oracle fga審計(欄位級)Oracle
- oracle增加欄位帶預設值Oracle
- oracle 修改表欄位的長度Oracle
- 查詢oracle欄位預設值Oracle
- ORACLE RAC+DG調整redo大小Oracle
- mysql資料庫新增和修改欄位MySql資料庫
- laravel生產環境下新增欄位Laravel
- [Elasticsearch] 多欄位搜尋 (二) - 最佳欄位查詢及其調優(轉)Elasticsearch
- SQL Server 2005效能調整二(zt)SQLServer
- Oracle 修改欄位型別和長度Oracle型別
- Oracle-批量修改欄位裡面的值Oracle
- Oracle 效能調優工具:SQL MonitorOracleSQL
- jpa~為欄位新增insert的預設值
- MybatisPlus經典示例:使用Wrapper查詢指定欄位並新增欄位函式處理MyBatisAPP函式
- 欄位管理,為什麼只有新增的時候才自動匹配欄位型別型別
- MAC新手教程:如何快速調整Dock欄的大小Mac
- buffer cache深度分析及效能調整(五)
- buffer cache深度分析及效能調整(四)
- buffer cache深度分析及效能調整(六)
- win10語言欄位置調整方法,win10語言欄怎麼調位置Win10
- 圖解MySQL:count(*) 、count(1) 、count(主鍵欄位)、count(欄位)哪個效能最好?圖解MySql
- oracle 11g rac新增節點前之清除節點資訊Oracle
- oracle複合索引介紹(多欄位索引)Oracle索引
- 新增一列並增加列欄位註釋
- 如果新增欄位是外來鍵,如何處理?