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效能調整之--DML語句效能調整Oracle
- oracle效能調整(1)Oracle
- oracle效能調整(2)Oracle
- ORACLE效能調整--1Oracle
- ORACLE效能調整---2Oracle
- Oracle 效能調整for HWOracle
- (zt)Oracle效能調整Oracle
- oracle效能調整2Oracle
- Oracle-欄位的新增Oracle
- 筆記: Oracle 11g效能調整(11.2)目錄筆記Oracle
- Oracle效能調整筆記Oracle筆記
- Oracle效能調整-1(轉)Oracle
- Oracle效能調整-2(轉)Oracle
- Oracle效能調整-3(轉)Oracle
- Oracle效能最佳化調整--調整重做機制Oracle
- Oracle效能調整的誤區Oracle
- Oracle高效能SQL調整OracleSQL
- oracle效能調整筆記[zt]Oracle筆記
- ORACLE之常用FAQ:效能調整Oracle
- Oracle 9i效能調整 [ZT]Oracle
- oracle效能優化-共享池調整Oracle優化
- Oracle效能調整指導綱要Oracle
- oracle資料庫的效能調整Oracle資料庫
- oracle效能優化(二)-調整查詢Oracle優化
- oracle高階效能調整培訓pptOracle
- oracle資料庫的效能調整(轉)Oracle資料庫
- oracle大表新增欄位default經驗分享Oracle
- SQL新增表欄位SQL
- 11g中關於表新增欄位default屬性研究
- Oracle效能最佳化調整--調整緩衝區快取記憶體Oracle快取記憶體
- 結合YAPP和STATSPAGK調整ORACLE效能APPOracle
- <轉>oracle效能調整讀書筆記(1)Oracle筆記
- <轉>oracle效能調整讀書筆記(2)Oracle筆記
- <轉>oracle效能調整讀書筆記(3)Oracle筆記
- <轉>oracle效能調整讀書筆記(4)Oracle筆記
- <轉>oracle效能調整讀書筆記(5)Oracle筆記
- Oracle 增加修改刪除欄位與新增註釋Oracle