一,创建
Data Block是数据库中最小的I/O单元
01,建立一个新的表空间
查看默认表空间位置
select TABLESPACE_NAME,FILE_NAME from dba_data_files;
创建一个表空间放其他的地方把
create tablespace test2 datafile '/orcl/app/table/test2.dbf' size 20m reuse autoextend on next 20m maxsize UNLIMITED extent management local;
02,创建用户
查看CDB
select name,cdb from v$database;
查看pDb
SQL> select pdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs; PDB_ID PDB_NAME DBID STATUS CREATION_SCN ---------- ----------------------------------------------------------------------------------- 3 ORCLPDB 3877422513 NORMAL 1442756 2 PDB$SEED 4118313826 NORMAL 1408751 4 HRPDB 1506437541 NORMAL 4081006 5 SALESPDB 1453096304 NORMAL 4087331
查看PDB状态
SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE ---------- ---------- ----------------------------------------------------- 2 4118313826 PDB$SEED READ ONLY 3 3877422513 ORCLPDB READ WRITE 4 1506437541 HRPDB READ ONLY 5 1453096304 SALESPDB READ ONLY
创建使用者为test
SQL> create user c##test identified by test; User created.
切换PDB
SQL> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=ORCLPDB;
Session altered.
SQL> show con_name;
CON_NAME
------------------------------
ORCLPDB
创建表空间
SQL> create tablespace test2 datafile '/orcl/app/table/test2.dbf' size 20M;
Tablespace created.
创建真正的用户
SQL> create user test identified by test default tablespace test2; User created.
授予权限
SQL> grant dba to test
Grant succeeded.
03,建立数据
SQL> create table t1 (id int,name varchar2(100)); Table created. SQL> insert into t1 values(1,'A'); 1 row created. SQL> alter system checkpoint; System altered. SQL> col name for a10 SQL> select id,name,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block# from t1; ID NAME FILE# BLOCK# ---------- ---------- ---------- ---------- 1 A 1 32641 SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid in (select userenv('sid') from dual); SPID ------------------------ 17124 SQL> alter system dump datafile 1 block 32641; System altered. SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid in (select userenv('sid') from dual); SPID ------------------------ 17124 SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid in (select userenv('sid') from dual); SPID ------------------------ 17124 SQL> select object_id from dba_objects where object_name='T1' and owner='SYS'; OBJECT_ID ---------- 75798
[oracle@node12c01 trace]$ more orcl_ora_20178.trc Trace file /orcl/app/oracle/diag/rdbms/node12c01/orcl/trace/orcl_ora_20178.trc Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production Build label: RDBMS_12.2.0.1.0_LINUX.X64_170125 ORACLE_HOME: /orcl/app/oracle/product/12.1.0/db_1 System name: Linux Node name: node12c01 Release: 3.10.0-693.el7.x86_64 Version: #1 SMP Tue Aug 22 21:09:27 UTC 2017 Machine: x86_64 Instance name: orcl Redo thread mounted by this instance: 1 Oracle process number: 36 Unix process pid: 20178, image: oracle@node12c01 (TNS V1-V3) *** 2019-04-16T05:29:55.899559-04:00 (CDB$ROOT(1)) *** SESSION ID:(31.49582) 2019-04-16T05:29:55.899596-04:00 *** CLIENT ID:() 2019-04-16T05:29:55.899601-04:00 *** SERVICE NAME:(SYS$USERS) 2019-04-16T05:29:55.899605-04:00 *** MODULE NAME:(sqlplus@node12c01 (TNS V1-V3)) 2019-04-16T05:29:55.899610-04:00 *** ACTION NAME:() 2019-04-16T05:29:55.899614-04:00 *** CLIENT DRIVER:(SQL*PLUS) 2019-04-16T05:29:55.899617-04:00 *** CONTAINER ID:(1) 2019-04-16T05:29:55.899621-04:00 Start dump data blocks tsn: 0 file#:1 minblk 32641 maxblk 32641 Block dump from cache: Dump of buffer cache at level 4 for pdb=1 tsn=0 rdba=4226945 Block dump from disk: buffer tsn: 0 rdba: 0x00407f81 (1/32641) scn: 0x5d140 seq: 0x01 flg: 0x06 tail: 0xd1400601 frmt: 0x02 chkval: 0x6c32 type: 0x06=trans data Hex dump of block: st=0, typ_found=1 Dump of memory from 0x00007FBF65C6A000 to 0x00007FBF65C6C000
分析:
数据头: buffer tsn: 0 rdba: 0x00419578 (1/103800) scn: 0x4ea6cf seq: 0x02 flg: 0x04 tail: 0xa6cf1002 frmt: 0x02 chkval: 0x5692 type: 0x10=DATA SEGMENT HEADER - UNLIMITED flg:0x01 (新建块)0x2(数据块延迟清洗推进scn和seq) 0X04(设置校验和) 0x08(临时块) type:0x06(表/索引块) frmt: 0x01(v7) 0x02(v8) Hex dump of block: st=0, typ_found=1 Dump of memory from 0x00007F12ACAA4000 to 0x00007F12ACAA6000 7F12ACAA4000 0000A210 00419578 004EA6CF 04020000 [....x.A...N.....] 7F12ACAA4010 00005692 00000000 00000000 00000000 [.V..............] 7F12ACAA4020 00000000 00000001 00000007 00001020 [............ ...] 7F12ACAA4030 00000000 00000003 00000007 0041957C [............|.A.] 7F12ACAA4040 00000000 00000000 00000001 00000003 [................] 7F12ACAA4050 00000000 00000000 00000000 00000001 [................] 7F12ACAA4060 00000000 000125D4 40000000 00419579 [.....%.....@y.A.] 7F12ACAA4070 00000007 00000000 00000000 00000000 [................] 7F12ACAA4080 00000000 00000000 00000000 00000000 [................] Repeat 250 times 7F12ACAA5030 00000000 00010000 00010001 00000001 [................] 7F12ACAA5040 00000000 00000003 0041957B 0041957B [........{.A.{.A.] 7F12ACAA5050 00000000 00000000 00000000 00000000 [................] Repeat 249 times 7F12ACAA5FF0 00000000 00000000 00000000 A6CF1002 [................]
http://www.itpub.net/thread-1772905-1-1.html