[20171206]最小資料檔案.txt
[20171206]最小資料檔案.txt
--//曾經寫過一篇關於[20150113]關於oracle的儲存結構.txt的文章,連結http://blog.itpub.net/267265/viewspace-1400603/
--//裡面提到如果建立的資料檔案如果SEGMENT SPACE MANAGEMENT AUTO (8K資料塊),最小檔案是88k.實際佔用大小96K.
--//是否可以建立更小的資料檔案呢?
1.環境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.建立測試指令碼:
$ cat guess_keep_128.sql
drop tablespace t01 including contents and datafiles;
CREATE TABLESPACE T01 DATAFILE
'/mnt/ramdisk/book/T01.dbf' SIZE &1 k reuse AUTOEXTEND OFF
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
create table emp2 tablespace t01 as select * from emp where rownum<=1;
column PARTITION_NAME noprint
select * from dba_extents where owner=user and segment_name='EMP2';
SCOTT@book> @ guess_keep_128.sql 80
drop tablespace t01 including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'T01' does not exist
old 2: '/mnt/ramdisk/book/T01.dbf' SIZE &1 k reuse AUTOEXTEND OFF
new 2: '/mnt/ramdisk/book/T01.dbf' SIZE 80 k reuse AUTOEXTEND OFF
CREATE TABLESPACE T01 DATAFILE
*
ERROR at line 1:
ORA-03214: File Size specified is smaller than minimum required
create table emp2 tablespace t01 as select * from emp where rownum<=1
*
ERROR at line 1:
ORA-00959: tablespace 'T01' does not exist
no rows selected
--//如果建立88K
drop tablespace t01 including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'T01' does not exist
old 2: '/mnt/ramdisk/book/T01.dbf' SIZE &1 k reuse AUTOEXTEND OFF
new 2: '/mnt/ramdisk/book/T01.dbf' SIZE 88 k reuse AUTOEXTEND OFF
Tablespace created.
Table created.
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------ -------------------- ------------------ ------------------------------ ---------- ---------- ---------- ---------- ---------- ------------
SCOTT EMP2 TABLE T01 0 7 4 65536 8 7
--//也就是oracle前面0-3塊保留.
--//第0塊OS塊,第1塊檔案頭,第2塊是點陣圖頭,第3塊是點陣圖區.
SCOTT@book> alter system dump datafile 7 block min 2 block max 3;
System altered.
$ grep "^frmt:" /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_31988.trc
frmt: 0x02 chkval: 0x8daf type: 0x1d=KTFB Bitmapped File Space Header
frmt: 0x02 chkval: 0x5956 type: 0x1e=KTFB Bitmapped File Space Bitmap
3.如果使用SEGMENT SPACE MANAGEMENT MANUAL呢?
--//不使用 EXTENT MANAGEMENT LOCAL AUTOALLOCATE,因為這樣1個extent=64K.
$ cat guess_size.sql
drop tablespace t02 including contents and datafiles;
CREATE TABLESPACE T02 DATAFILE
'/mnt/ramdisk/book/T02.dbf' SIZE & K AUTOEXTEND OFF
LOGGING
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 8K
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;
create table emp2 tablespace t02 as select * from emp where rownum<=1;
column PARTITION_NAME noprint
select * from dba_extents where owner=user and segment_name='EMP2';
--//注:實際上根本不能建立UNIFORM SIZE 8K的資料檔案,最少2塊.這裡僅僅不報錯罷了.
--//先猜測看看,第0塊OS塊,第1塊檔案頭,第2塊是點陣圖頭,第3塊是點陣圖區.資料至少2塊.這樣建立的資料檔案最少5塊.
--//也就是40K.
SCOTT@book> @ guess_size.sql 40
drop tablespace t02 including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'T02' does not exist
old 2: '/mnt/ramdisk/book/T02.dbf' SIZE &1 K AUTOEXTEND OFF
new 2: '/mnt/ramdisk/book/T02.dbf' SIZE 40 K AUTOEXTEND OFF
Tablespace created.
Table created.
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------ -------------------- ------------------ ------------------------------ ---------- ---------- ---------- ---------- ---------- ------------
SCOTT EMP2 TABLE T02 0 8 4 16384 2 8
--//可以發現佔2塊.也就是每個extents最小16K.
$ ls -lh /mnt/ramdisk/book/T02.dbf
-rw-r----- 1 oracle oinstall 48K 2017-12-06 11:16:10 /mnt/ramdisk/book/T02.dbf
--//最小佔48K.
--//再小一點到32K看看.
SCOTT@book> @ guess_size.sql 32
Tablespace dropped.
old 2: '/mnt/ramdisk/book/T02.dbf' SIZE &1 K AUTOEXTEND OFF
new 2: '/mnt/ramdisk/book/T02.dbf' SIZE 32 K AUTOEXTEND OFF
CREATE TABLESPACE T02 DATAFILE
*
ERROR at line 1:
ORA-03214: File Size specified is smaller than minimum required
create table emp2 tablespace t02 as select * from emp where rownum<=1
*
ERROR at line 1:
ORA-00959: tablespace 'T02' does not exist
no rows selected
--//對於資料檔案8K塊大小,能建立的最小資料檔案是40K,包括OS塊頭,48K.
--//當然如果資料塊大小2K,這樣建立的最小的資料檔案就是10K.
alter system set db_2k_cache_size=1M scope=spfile;
--//重啟..
$ cat guess_size1.sql
drop tablespace t03 including contents and datafiles;
CREATE TABLESPACE T03 DATAFILE
'/mnt/ramdisk/book/T03.dbf' SIZE &1 K AUTOEXTEND OFF
LOGGING
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 2K
BLOCKSIZE 2K
SEGMENT SPACE MANAGEMENT MANUAL
FLASHBACK ON;
create table emp2 tablespace t03 as select * from emp where rownum<=1;
column PARTITION_NAME noprint
select * from dba_extents where owner=user and segment_name='EMP2';
SCOTT@book> @ guess_size1.sql 10
drop tablespace t03 including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'T03' does not exist
old 2: '/mnt/ramdisk/book/T03.dbf' SIZE &1 K AUTOEXTEND OFF
new 2: '/mnt/ramdisk/book/T03.dbf' SIZE 10 K AUTOEXTEND OFF
Tablespace created.
Table created.
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------ -------------------- ------------------ ------------------------------ ---------- ---------- ---------- ---------- ---------- ------------
SCOTT EMP2 TABLE T03 0 8 4 4096 2 8
$ ls -l /mnt/ramdisk/book/T03.dbf
-rw-r----- 1 oracle oinstall 12288 2017-12-06 11:25:45 /mnt/ramdisk/book/T03.dbf
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2148337/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20171206]點陣圖區一定在資料檔案開頭嗎.txt
- Python提取文字檔案(.txt)資料的方法Python
- [20170221]資料檔案與檔案系統快取.txt快取
- [20171206]SQLTUNE_CATEGORY引數.txtSQLGo
- [20190410]dg建立臨時表檔案資料檔案.txt
- python如何將資料寫入本地txt文字檔案Python
- [20160329]表空間與資料檔案.txt
- openfiledialog 使用 讀取txt檔案 StreamReader 檢驗資料
- python實現將資料夾內所有txt檔案合併成一個檔案Python
- php如何上傳txt檔案,並且讀取txt檔案PHP
- PCL——txt檔案轉到PCD檔案
- python實現圖書管理系統——通過excel檔案或者TXT檔案存放資料PythonExcel
- [20121105]重建控制檔案少一個資料檔案的情況.txt
- [20140918]資料泵與外部檔案.txt
- [20121114]Oracle資料檔案大小限制.txtOracle
- [20130104]快速移動資料檔案.txt
- 建立資料庫檔案-日誌檔案-次要資料庫檔案資料庫
- 資料檔案
- [20181102]資料檔案改名與awr.txt
- [20161110]資料檔案的第0塊.txt
- [20151125]資料檔案的unrecover.txt
- [20150527]bbed解決資料檔案大小問題.txt
- [20160329]bbed修復offline的資料檔案.txt
- Delphi程式設計:用流來讀取TXT檔案中的資料程式設計
- Oracle 匯出txt檔案Oracle
- python讀取資料集檔案下所有檔案並打亂劃分生成訓練測試txt檔案(生成train.txt、test.txt,順序隨機,預設比例8:2)PythonAI隨機
- oracle資料庫移動資料檔案、日誌檔案和控制檔案Oracle資料庫
- SQLSERVER匯出TXT文字檔案,ORACLE SQL LOADER匯入TXT文字檔案SQLServerOracle
- 資料庫檔案和檔案組資料庫
- 資料庫引數檔案控制檔案日誌檔案資料檔案跟蹤檔案等8大檔案的字典資料庫
- [20181031]12c 線上移動資料檔案.txt
- [20180718]拷貝資料檔案從dg庫.txt
- [20230224]改動資料檔案小技巧.txt
- [20161108]關於資料檔案的問題.txt
- [20161031]rman備份與資料檔案OS塊.txt
- [20171225]沒有備份資料檔案的恢復.txt
- 檔案與資料
- 資料泵檔案