SQL> alter session set ddl_lock_timeout = 100 ;
Session altered.
SQL> show parameters ddl_lock_timeout
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
ddl_lock_timeout integer 100
SQL> alter system set ddl_lock_timeout=200 ;
System altered.
SQL> show parameters ddl_lock_timeout
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
ddl_lock_timeout integer 200
h3.2. 컬럼 추가 기능 향상
SQL> create table sales (
2 sales_id number,
3 cust_id number,
4 sales_amt number,
5 sales_category varchar2(6)
6 generated always as
7 ( case
8 when sales_amt <= 10000 then 'LOW'
9 when sales_amt > 10000 and sales_amt <= 100000 then 'MEDIUM'
10 when sales_amt > 100000 and sales_amt <= 1000000 then 'HIGH'
11 else 'ULTRA'
12 end
13 ) virtual
14 ) ;
Table created.
SQL> create index in_sales_cat on sales ( sales_category ) ;
Index created.
SQL> select index_type from user_indexes where index_name ='IN_SALES_CAT';
INDEX_TYPE
---------------------------------------------------------------------------------
FUNCTION-BASED NORMAL
SQL> select column_expression from user_ind_expressions where index_name ='IN_SALES_CAT';
COLUMN_EXPRESSION
--------------------------------------------------------------------------------
CASE WHEN "SALES_AMT"<=10000 THEN 'LOW' WHEN ("SALES_AMT">10000 AND "SALES_AMT"
<=100000) THEN 'MEDIUM' WHEN ("SALES_AMT">100000 AND "SALES_AMT"<=1000000) THEN
'HIGH' ELSE 'ULTRA' END
SQL> insert into sales values (5,100,300,'HIGH','XX') ;
insert into sales values (5,100,300,'HIGH','XX')
*
ERROR at line 1:
ORA-00913: too many values
SQL> alter index <인덱스명> invisible ;
Index altered.
SQL> alter index <인덱스명> visible ;
Index altered.
SQL> create table res ( a1 number, a2 varchar2(100)) ;
Table created.
SQL> begin
2 for i in 1 .. 10000 loop
3 insert into res values ( i, 'TEST');
4 end loop ;
5 commit ;
6 end ;
7 /
PL/SQL procedure successfully completed.
SQL> commit ;
Commit complete.
SQL> create index in_res_a1 on res ( a1 ) ;
Index created.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------
SQL_ID d19nv7npgnd2g, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from res where a1=1
Plan hash value: 989048864
---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 4 |
| 1 | TABLE ACCESS BY INDEX ROWID| RES | 1 | 1 | 1 |00:00:00.01 | 4 |
|* 2 | INDEX RANGE SCAN | IN_RES_A1 | 1 | 1 | 1 |00:00:00.01 | 3 |
---------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("A1"=1)
Note
-----
- dynamic sampling used for this statement (level=2)
23 rows selected.
SQL> alter index in_res_a1 invisible ;
Index altered.
SQL> select /*+ gather_plan_statistics */ * from res where a1=1 ;
SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------
SQL_ID d19nv7npgnd2g, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from res where a1=1
Plan hash value: 3824022422
------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 24 |
|* 1 | TABLE ACCESS FULL| RES | 1 | 1 | 1 |00:00:00.01 | 24 |
------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("A1"=1)
Note
-----
- dynamic sampling used for this statement (level=2)
22 rows selected.
SQL> select visibility from user_indexes where index_name ='IN_RES_A1';
VISIBILITY
---------------------------
INVISIBLE
SQL> alter table xxxx read only ;
Table altered.
SQL> alter table xxxx read write ;
Table altered.
SQL> select read_only from dba_tables where table_name ='RES';
READ_ONLY
---------
YES
Elapsed: 00:00:00.28
SQL> select count(*) from RES ;
COUNT(*)
----------
10000
SQL> delete RES ;
delete RES
*
ERROR at line 1:
ORA-12081: update operation not allowed on table "SYS"."RES"
SQL> truncate table RES ;
truncate table RES
*
ERROR at line 1:
ORA-12081: update operation not allowed on table "SYS"."RES"