global temporary table index

-----session 1

create global temporary table T_FORM4_POL_CHG_TMP
(
POLICY_ID NUMBER(10) not null,
CHANGE_ID NUMBER(10),
SERVICE_ID NUMBER(10),
FINISH_TIME DATE,
CASE_ID NUMBER(10),
WITHDRAW_TIME DATE,
CHANGE_STATUS VARCHAR2(2)
)
on commit delete rows;
-- Create/Recreate indexes
create index TMP_IND_D1 on T_FORM4_POL_CHG_TMP (POLICY_ID);

SQL> begin
2 for i in 1..5000000 loop
3 insert into t_form4_pol_chg_tmp values(i,i,i,null,i,null,'TW');
4 end loop;
5 end;
6 /

----- session 2

SQL> l
1 select se.username
2 ,se.sid
3 ,su.extents
4 ,su.blocks * to_number(rtrim(p.value)) as Space
5 ,tablespace
6 ,segtype
7 ,sql_text
8 from v$sort_usage su
9 ,v$parameter p
10 ,v$session se
11 ,v$sql s
12 where p.name = 'db_block_size'
13 and su.session_addr = se.saddr
14 and s.hash_value = su.sqlhash and s.address = su.sqladdr
15* order by se.username, se.sid
SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 70 73400320
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 151 158334976
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 72 75497472
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 155 162529280
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 79 82837504
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 170 178257920
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 79 82837504
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 170 178257920
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 81 84934656
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 175 183500800
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 81 84934656
TEMP INDEX
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

HXG 146 175 183500800
TEMP DATA
INSERT INTO T_FORM4_POL_CHG_TMP VALUES(:B1 ,:B1 ,:B1 ,NULL,:B1 ,NULL,'TW')

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 83 87031808
TEMP INDEX
begin for i in 1..5000000 loop insert into t_form4_pol_chg_tmp values(i,i,i,null
,i,null,'TW'); end loop; end;

HXG 146 179 187695104
TEMP DATA

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
begin for i in 1..5000000 loop insert into t_form4_pol_chg_tmp values(i,i,i,null
,i,null,'TW'); end loop; end;


SQL> /

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
HXG 146 83 87031808
TEMP INDEX
begin for i in 1..5000000 loop insert into t_form4_pol_chg_tmp values(i,i,i,null
,i,null,'TW'); end loop; end;

HXG 146 179 187695104
TEMP DATA

USERNAME SID EXTENTS SPACE
------------------------------ ---------- ---------- ----------
TABLESPACE SEGTYPE
------------------------------- ---------
SQL_TEXT
--------------------------------------------------------------------------------
begin for i in 1..5000000 loop insert into t_form4_pol_chg_tmp values(i,i,i,null
,i,null,'TW'); end loop; end;

-----session 1

SQL> begin
2 for i in 1..5000000 loop
3 insert into t_form4_pol_chg_tmp values(i,i,i,null,i,null,'TW');
4 end loop;
5 end;
6 /

PL/SQL 过程已成功完成。

SQL> select count(*) from t_form4_pol_chg_tmp;

COUNT(*)
----------
5000000

SQL> commit;

提交完成。

SQL> select count(*) from t_form4_pol_chg_tmp;

COUNT(*)
----------
0

------session 2:

SQL> l
1 select se.username
2 ,se.sid
3 ,su.extents
4 ,su.blocks * to_number(rtrim(p.value)) as Space
5 ,tablespace
6 ,segtype
7 ,sql_text
8 from v$sort_usage su
9 ,v$parameter p
10 ,v$session se
11 ,v$sql s
12 where p.name = 'db_block_size'
13 and su.session_addr = se.saddr
14 and s.hash_value = su.sqlhash and s.address = su.sqladdr
15* order by se.username, se.sid
SQL> /

未选定行

你可能感兴趣的:(temporary)