37. SQL> set errorlogging on
SQL> desc SPERRORLOG
Name Type
------------------------------------- ----------------
USERNAME VARCHAR2(256)
TIMESTAMP TIMESTAMP(6)
SCRIPT VARCHAR2(1024)
IDENTIFIER VARCHAR2(256)
MESSAGE CLOB
STATEMENT CLOB
37
38. SQL> select * from THE_WRONG_NAME;
select * from THE_WRONG_NAME
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> desc THE_WRONG_NAME;
ERROR:
ORA-04043: object THE_WRONG_NAME does not exist
SQL> grant execute on P to NOT_A_USER;
grant execute on P to NOT_A_USER
*
ERROR at line 1:
ORA-01917: user or role 'NOT_A_USER' does not exist
38
39. SQL> select timestamp, message, statement
2 from SPERRORLOG;
TIMESTAMP
-----------------------------------------------------
MESSAGE
-----------------------------------------------------
STATEMENT
-----------------------------------------------------
01-APR-08 02.29.58.000000 PM
ORA-00942: table or view does not exist
select * from THE_WRONG_NAME
01-APR-08 02.29.58.000000 PM
ORA-04043: object THE_WRONG_NAME does not exist
desc THE_WRONG_NAME;
01-APR-08 02.30.04.000000 PM
ORA-01917: user or role "NOT_A_USER" does not exist
grant execute on P to NOT_A_USER
39
40. SQL> set errorlogging on
SQL> @create_all_objects
installation scripts
works on 10g too…
40
49. SQL> select deptno, ename
2 from emp
3 order by 1,2;
DEPTNO ENAME
---------- ----------
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
49
51. SQL> select deptno , rtrim(ename,',') enames
2 from ( select deptno,ename,rn
3 from emp
4 model
5 partition by (deptno)
6 dimension by (
7 row_number() over
8 (partition by deptno order by ename) rn
9 )
10 measures (cast(ename as varchar2(40)) ename)
11 rules
12 ( ename[any]
13 order by rn desc = ename[cv()]||','||ename[cv()+1])
14 )
15 where rn = 1
16 order by deptno;
DEPTNO ENAMES
---------- ----------------------------------------
10 CLARK,KING,MILLER
20 ADAMS,FORD,JONES,SCOTT,SMITH
30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
- Rob Van Wijk 51
52. SQL> select deptno,
2 substr(max(sys_connect_by_path(ename, ',')), 2) members
3 from (select deptno, ename,
4 row_number ()
5 over (partition by deptno order by empno) rn
6 from emp)
7 start with rn = 1
8 connect by prior rn = rn - 1
9 and prior deptno = deptno
10 group by deptno
11 /
DEPTNO MEMBERS
---------- ---------------------------------------------------------
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
20 SMITH,JONES,SCOTT,ADAMS,FORD
10 CLARK,KING,MILLER
- Anon 52
54. SQL> create or replace type string_agg_type as object
2 (
3 total varchar2(4000),
4
5 static function
6 ODCIAggregateInitialize(sctx IN OUT string_agg_type )
7 return number,
8
9 member function
10 ODCIAggregateIterate(self IN OUT string_agg_type ,
11 value IN varchar2 )
12 return number,
13
14 member function
15 ODCIAggregateTerminate(self IN string_agg_type,
16 returnValue OUT varchar2,
17 flags IN number)
18 return number,
19
20 member function
21 ODCIAggregateMerge(self IN OUT string_agg_type,
22 ctx2 IN string_agg_type)
23 return number
24 );
25 /
- Tom Kyte 54
56. SQL> select deptno,
2 listagg( ename, ',')
3 within group (order by empno) members
4 from emp
5 group by deptno;
DEPTNO MEMBERS
---------- -----------------------------------------
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FORD
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
56
59. select e.department_id, sum(salary)
from emp e,
job_hist j
where e.employee_id = j.employee_id
and extract(year from e.hire_date) > 1985
and j.end_date > j.start_date + 1
and j.start_date >= e.hire_date
group by e.department_id
59
73. SQL> desc VEHICLE
Name Null? Type
-------------------------- -------- -------------
ID NUMBER
MAKE VARCHAR2(6)
MODEL VARCHAR2(6)
SQL> select count(*)
2 from VEHICLE;
COUNT(*)
------------
2,157,079
73
73
87. SQL> select count(*) from VEHICLE where model = 'COMMODORE';
COUNT(*)
----------
214468
SQL> select count(*) from VEHICLE where make = 'HOLDEN';
COUNT(*)
----------
415387 Prob(xy)=Prob(x)*Prob(y)
SQL> select (214468/2157079)*
2 (415387/2157079)*
3 2157079 EST_ROWS from dual;
EST_ROWS
---------------
41299.9334 ≈ 39527
87
87
88. SQL> select
2 DBMS_STATS.CREATE_EXTENDED_STATS(
3 user, 'VEHICLE','(MAKE,MODEL)') tag
4 from dual;
TAG
----------------------------------
SYS_STU8QPK2S$PEWHARK2CP3#1F#G
SQL> select COLUMN_NAME,NUM_DISTINCT
2 from USER_TAB_COLS
3 where table_name = 'VEHICLE'
COLUMN_NAME NUM_DISTINCT
------------------------------ ------------
ID 2157079
MAKE 39
MODEL 292
SYS_STU8QPK2S$PEWHARK2CP3#1F#G
88
88
98. PARSING IN CURSOR #28
alter table "SH"."VEHICLE" add
(SYS_STU8QPK2S$PEWHARK2CP3#1F#G
as (SYS_OP_COMBINED_HASH(MAKE,MODEL))
virtual BY USER for statistics);
END OF STMT
98
98
134. memory
SQL> SELECT name, value
2 FROM v$parameter
3 WHERE name LIKE 'result_cache%';
NAME VALUE
------------------------------ -----------
result_cache_mode MANUAL
result_cache_max_size 1081344
result_cache_max_result 5
result_cache_remote_expiration 0
%
134
135. SQL> set autotrace traceonly stat
SQL> set timing on
SQL> select owner, count(*)
2 from T
3 group by owner
4 /
29 rows selected.
Elapsed: 00:00:03.98
Statistics
-----------------------------------------------------
0 recursive calls
1 db block gets
32192 consistent gets
32184 physical reads
96 redo size
[snip]
135
142. SQL> set timing on
SQL> select /*+ RESULT_CACHE */ owner, count(*)
2 from T
3 group by owner
4 /
29 rows selected.
Elapsed: 00:00:00.05
SQL> delete from T where rownum = 1;
1 row deleted.
SQL> select /*+ RESULT_CACHE */ owner, count(*)
2 from T
3 group by owner
4 /
active txn
Elapsed: 00:00:03.91
142
143. SQL> commit;
Commit complete.
SQL> select /*+ RESULT_CACHE */ owner, count(*)
2 from T
3 group by owner
4 /
Elapsed: 00:00:03.91 reinstantiate cache
SQL> select /*+ RESULT_CACHE */ owner, count(*)
2 from T
3 group by owner
4 /
Elapsed: 00:00:00.04
voila!
143
149. SQL> select
2 r.name,
3 listagg(o.name,' ') within group ( order by o.name ) as obj
4 from v$result_cache_objects r,
5 v$result_cache_dependency d,
6 sys.obj$ o
7 where r.type = 'Result'
8 and r.id =d.result_id
9 and d.object_no=o.obj#
10 group by r.name;
NAME OBJ
------------------------------------------------ ----------------
select /*+ RESULT_CACHE */ owner, count(*) T
from T
group by owner
select /*+ RESULT_CACHE */ owner, count(*) T1 T
from T, T1
group by owner
149
151. SQL> desc COUNTRY_SALES
Name Null? Type
----------------- -------- ------------
CTRY NOT NULL VARCHAR2(10)
CRNCY NOT NULL VARCHAR2(3)
AMOUNT NUMBER
PRODUCT VARCHAR2(20)
TXN_DATE DATE
QUANTITY NUMBER(3)
"summarise the sales in $AUD"
151
160. SQL> select /*+ RESULT_CACHE */ owner, max(object_id)
2 from T
3 group by owner
4 /
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 19 | 171 |
| 1 | RESULT CACHE | b82qdu5m139yr3fbna1x5r6g2d | | |
| 2 | HASH GROUP BY | | 19 | 171 |
| 3 | TABLE ACCESS FULL| T | 2201K| 18M |
--------------------------------------------------------------------------
indeterminate
160
161. SQL> select status
2 from v$result_cache_objects
3 where cache_id = 'b82qdu5m139yr3fbna1x5r6g2d';
STATUS
---------
Published
? New -
Published -
Result is still under construction
Result is available for use
Bypass - Result will be bypassed from use
Expired - Result has exceeded expiration time
Invalid - Result is no longer available for use
161
180. SQL> desc T
Name Null? Type
----------------------------- -------- -------------
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SQL> desc T_AUDIT
Name Null? Type
----------------------------- -------- --------------
AUDIT_DATE DATE
AUDIT_ACTION CHAR(1)
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
180
181. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) := case when updating then 'U'
7 when deleting then 'D' else 'I' end;
8 begin
9 if updating or inserting then
10 insert into T_AUDIT
11 values (sysdate
12 ,v_action
13 ,:new.owner
14 ,:new.object_name);
15 else
16 insert into T_AUDIT
17 values (sysdate
18 ,v_action
19 ,:old.owner
20 ,:old.object_name);
21 end if;
22 end;
23 /
Trigger created.
181
185. create or replace
package T_PKG is
type each_row is record ( action varchar2(1),
owner varchar2(30),
object_name varchar2(30)
);
type row_list is table of each_row
index by pls_integer;
g row_list;
end;
/
185
186. create or replace
trigger AUDIT_TRG1
before insert or update or delete on T
begin
t_pkg.g.delete;
end;
/
186
187. create or replace
trigger AUDIT_TRG2
after insert or update or delete on T
for each row
begin
if updating or inserting then
t_pkg.g(t_pkg.g.count+1).owner := :new.owner;
t_pkg.g(t_pkg.g.count).object_name := :new.object_name;
else
t_pkg.g(t_pkg.g.count).owner := :old.owner;
t_pkg.g(t_pkg.g.count).object_name := :old.object_name;
end if;
end;
/
187
188. create or replace
trigger AUDIT_TRG3
after insert or update or delete on T
declare
v_action varchar2(1) :=
case when updating then 'U'
when deleting then 'D'
else 'I' end;
begin
forall i in 1 .. t_pkg.g.count
insert into T_AUDIT
values (
sysdate,
v_action,
t_pkg.g(i).owner,
t_pkg.g(i).object_name);
t_pkg.g.delete;
end;
/
188
189. SQL> insert into T
2 select owner, object_name
3 from all_objects
insert into T
4 where rownum <= 10000;
select owner, object_name
from all_objects
10000 rows created.
where rownum <= 10000
call count cpu elapsed disk query current rows
------- ------ ------- --------- -------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 33 0 0
Execute 1 0.56 0.58 0 91 10653 10000
Fetch 0 0.00 0.00 0 0 0 0
------- ------ ------- --------- -------- ---------- ---------- ----------
total 2 0.56 0.59 0 124 10653 10000
INSERT INTO T_AUDIT
VALUES
( SYSDATE, :B1 , :B2 , :B3 )
call count cpu elapsed disk query current rows
------- ------ ------- --------- -------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.04 0.03 0 90 478 10000
Fetch 0 0.00 0.00 0 0 0 0
------- ------ ------- --------- -------- ---------- ---------- ----------
total 2 0.04 0.03 0 90 478 10000
189
192. create or replace
trigger AUDIT_TRG for insert or update or delete on T
compound trigger
before statement is
begin
...
end before statement;
after each row is
begin
...
end after each row;
after statement is
begin
...
end after statement;
end;
/
192
193. SQL> create or replace
2 trigger AUDIT_TRG for insert or update or delete on T compound trigger
3
4 type each_row is record ( action varchar2(1),
5 owner varchar2(30),
6 object_name varchar2(30));
7 type row_list is table of each_row index by pls_integer;
8 g row_list;
9 v_action varchar2(1) :=
10 case when updating then 'U' when deleting then 'D' else 'I' end;
11
12 before statement is
13 begin
14 g.delete;
15 end before statement;
16
17 after each row is
18 begin
19
20 if updating or inserting then
21 g(g.count+1).owner := :new.owner;
22 g(g.count).object_name := :new.object_name;
23 else
24 g(g.count).owner := :old.owner;
25 g(g.count).object_name := :old.object_name;
26 end if;
27 end after each row;
28
29 after statement is
30 begin
31 forall i in 1 .. g.count
32 insert into T_AUDIT
33 values (sysdate,v_action,g(i).owner,g(i).object_name);
34 g.delete;
35 end after statement;
36
37 end;
38 /
193
Trigger created.
196. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) :=
7 case when updating then 'U'
8 when deleting then 'D' else 'I' end case;
9 begin
10 if updating or inserting then
11 insert into T_AUDIT
12 values(sysdate,v_action,:new.owner,:new.object_name);
13 else
14 insert into T_AUDIT
15 values(sysdate,v_action,:old.owner,:old.object_name);
16 end if;
17 end;
18 /
Warning: Trigger created with compilation errors.
SQL> sho err
Errors for TRIGGER AUDIT_TRG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
4/46 PLS-00103: Encountered the symbol "CASE" when expecting one of
the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2 196
197. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) :=
7 case when updating then 'U'
8 when deleting then 'D' else 'I' end;
9 begin
10 if updateing or inserting then
11 insert into T_AUDIT
12 values(sysdate,v_action,:new.owner,:new.object_name);
13 else
14 insert into T_AUDIT
15 values(sysdate,v_action,:old.owner,:old.object_name);
16 end if;
17 end;
18 /
Warning: Trigger created with compilation errors.
SQL> sho err
Errors for TRIGGER AUDIT_TRG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
6/3 PL/SQL: Statement ignored
6/6 PLS-00201: identifier 'UPDATEING' must be declared
197
198. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) :=
7 case when updating then 'U'
8 when deleting then 'D' else 'I' end;
9 begin
10 if updating or inserting then
11 insert into TAUDIT
12 values(sysdate,v_action,:new.owner,:new.object_name);
13 else
14 insert into T_AUDIT
15 values(sysdate,v_action,:old.owner,:old.object_name);
16 end if;
17 end;
18 /
Warning: Trigger created with compilation errors.
SQL> sho err
Errors for TRIGGER AUDIT_TRG:
LINE/COL ERROR
-------- ------------------------------------------------------
7/6 PL/SQL: SQL Statement ignored
7/18 PL/SQL: ORA-00942: table or view does not exist
198
199. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) :=
7 case when updating then 'U'
8 when deleting then 'D' else 'I' end;
9 begin
10 if updating or inserting then
11 insert into T_AUDIT
12 values(sysdate,v_action,:new.owner,new.object_name);
13 else
14 insert into T_AUDIT
15 values(sysdate,v_action,:old.owner,:old.object_name);
16 end if;
17 end;
18 /
Warning: Trigger created with compilation errors.
SQL> sho err
Errors for TRIGGER AUDIT_TRG:
LINE/COL ERROR
-------- ---------------------------------------------------------
10/6 PL/SQL: SQL Statement ignored
11/45 PL/SQL: ORA-00984: column not allowed here
199
203. SQL> insert into T values ('X','Y');
insert into T values ('X','Y')
*
ERROR at line 1:
ORA-04098: trigger 'CONNOR.AUDIT_TRG' is
invalid and failed re-validation
203
205. SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 DISABLE
6 declare
7 v_action varchar2(1) :=
8 case when updating then 'U'
9 when deleting then 'D' else 'I' end;
10 begin
11 if updating or inserting then
12 insert into T_AUDIT
13 values(sysdate,v_action,:new.owner,:new.object_name);
14 else
15 insert into T_AUDIT
16 values(sysdate,v_action,:old.owner,old.object_name);
17 end if;
18 end;
19 /
Warning: Trigger created with compilation errors.
205
206. SQL> select status from user_triggers
2 where trigger_name = 'AUDIT_TRG';
STATUS
--------
DISABLED
SQL> insert into T values ('X','Y');
1 row created.
206
209. SQL> create table T ( x number, y number );
Table created.
SQL> create or replace
2 view MY_VIEW as
3 select x,y from T;
View created.
209
210. SQL> alter table T add Z number;
Table altered.
SQL> select status
2 from user_objects
3 where object_name = 'MY_VIEW';
STATUS
-------
INVALID
210
223. pack A pack B pack C pack D
body A body B body C body D
223
224. SQL> create or replace
2 package PKG is
3 procedure P1;
4 end;
5 /
SQL> create or replace
Package created.
2 procedure PRC is
3 begin
SQL> create or replace
4 pkg.p1;
2 package body PKG is
3 5 end;
procedure P1 is
4 x6 /
number;
5 begin
6 Procedure created.
x := 1;
7 end;
8 end;
9 /
Package body created.
224
225. SQL> create or replace
2 package PKG is
3 procedure P1;
4 procedure P2;
5 end;
6 /
Package created.
SQL> create or replace
2 package body PKG is
3 procedure P1 is
4 x number;
5 begin
6 x := 1;
7 end;
8
9 procedure p2 is
10 x number;
11 begin
12 x := myseq.nextval;
13 end;
14 end;
15 /
Package body created.
225
226. SQL> select status
10g and below
2 from user_objects
3 where object_name = 'PRC';
STATUS
-------
INVALID
SQL> select status
11g
2 from user_objects
3 where object_name = 'PRC';
STATUS
-------
VALID
226
229. SQL> create or replace
2 package PKG is
3 procedure p1;
4 end;
5 /
Package created.
SQL> create or replace
2 package body PKG is
3 procedure p1 is
4 x number;
5 begin
6 x := 1;
7 end;
8
9 end;
10 /
Package body created.
229
230. SQL> create or replace
2 package PKG is
3 procedure p2;
4 procedure p1;
5 end;
6 /
Package created.
SQL> create or replace
2 package body PKG is
3 procedure p2 is
4 x number;
5 begin
6 x := myseq.nextval;
7 end;
8
9 procedure p1 is
10 x number;
11 begin
12 x := 1;
13 end;
14
15 end;
16 /
Package body created. 230
235. SQL> create or replace
2 package PKG is
3 procedure p1;
4 end;
5 /
Package created.
SQL> create or replace
2 package body PKG is
3
4 my_global_var date;
5
6 procedure p1 is
7 x number;
8 begin
9 if my_global_var is null then
10 my_global_var := sysdate;
11 end if;
12 end;
13 end;
14 /
Package body created.
235
236. SQL> create or replace
2 procedure PRC is
3 begin
SQL> create or replace
4 pkg.p1;
2 package body PKG is
5 end;
3
6 /
4 my_global_var date;
5
Procedure created.
6 procedure p1 is
7 x number;
SQL> exec PRC;
8 begin
9 if my_global_var is null then
SQL> exec PRC;
10 my_global_var := sysdate;
11 end if;
BEGIN PRC; END;
12 end;
13 end;
*
14 /
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
Package body created.
ORA-04061: existing state of package body "PKG" has been invalidated
ORA-04065: not executed, altered or dropped package body "PKG"
ORA-06508: PL/SQL: could not find program unit being called: "PKG"
ORA-06512: at "PRC", line 3
ORA-06512: at line 1
236
239. SQL> create or replace
2 package body PKG is
3 procedure p2 is
4 x number;
5 begin
6 x := myseq.nextval;
7 end;
8
9 procedure p1 is
10 x number;
11 begin
12 x := 1;
13 end;
14
15 end;
16 /
Package body created.
239
257. create view V_MY_TABLE as
select V1_COL1 as col1,
V1_COL2 as col2, version1
V1_COL3 as col3,
V1_ONLY_COL4 as col4,
from MY_TABLE
SQL> desc MY_TABLE
Name Null? Type
----------------------------- -------- -----------------
V1_COL1 NUMBER
V1_COL2 DATE
V1_COL3 VARCHAR2(10)
V1_ONLY_COL4 VARCHAR2(10)
V2_NEWCOL5 DATE
V2_NEWCOL6 NUMBER
create view V_MY_TABLE as
select V1_COL1 as col1,
V1_COL2 as col2,
V1_COL3 as col3, version2
V2_NEWCOL5 as col5,
V2_NEWCOL6 as col6
from MY_TABLE
257
260. SQL> desc EMP
Name Null? Type
----------------------------- -------- -------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
260
261. SQL> create or replace
2 package body EMP_MAINT is
3 procedure hire_emp(p_empno emp.empno%type,
4 p_ename emp.ename%type,
5 p_job emp.job%type,
6 p_sal emp.sal%type,
7 p_deptno emp.deptno%type) is
8 begin
9 insert into EMP
10 (empno,ename,job,sal,deptno)
11 values
12 (p_empno,p_ename,p_job,p_sal,p_deptno);
13 end;
14 end;
15 /
Package body created.
261
263. SQL> desc EMP
Name Null? Type
----------------------------- -------- -------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE Contract/Permanent DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
ETYPE VARCHAR2(10)
TERMINATION_DATE DATE
End of Contract
263
267. SQL> exec EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10)
BEGIN EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10); END;
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SCOTT"."EMP"."ETYPE")
ORA-06512: at "SCOTT.EMP_MAINT", line 8
ORA-06512: at line 1
267
286. SQL> grant USE on edition APP_V2 to SCOTT;
Grant succeeded.
286
287. SQL> alter session set edition = APP_V2;
SQL> create or replace
2 editioning view EMP as
3 select * from "_EMP"
4 /
View created.
287
288. SQL> alter session set edition = ORA$BASE;
Session altered.
SQL> desc EMP
Name Null? Type
----------------------------- -------- ----------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
288
289. SQL> alter session set edition = APP_V2;
Session altered.
SQL> desc EMP
Name Null? Type
----------------------------- -------- ---------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
ETYPE VARCHAR2(10)
TERMINATION_DATE DATE
289
307. SQL> alter session set edition = ORA$BASE;
Session altered.
SQL> declare
2 ok boolean;
3 scn number;
4 begin
5 ok :=
6 dbms_utility.wait_on_pending_dml('"_EMP"',10, scn);
7
8 if ok then
9 update EMP set sal=sal;
10 end if;
11 end;
12 /
PL/SQL procedure successfully completed.
307
326. SQL> connect / as sysdba
Connected.
sys@db112> alter user TO_BE_EDITIONED enable editions;
alter user TO_BE_EDITIONED enable editions
*
ERROR at line 1:
ORA-38819: user TO_BE_EDITIONED owns one or more
objects whose type is editionable and that have
noneditioned dependent objects
326
327. SQL> alter user TO_BE_EDITIONED enable editions FORCE;
User altered.
327
328. SQL> select owner, object_name, status
2 from dba_objects
3 where owner in (
4 'TO_BE_EDITIONED',
5 'NOT_EDITIONED');
OWNER OBJECT_NAME STATUS
--------------- ------------------- -------
TO_BE_EDITIONED EMP VALID
NOT_EDITIONED MY_EMPV INVALID
328
330. sys@db112> alter user TO_BE_EDITIONED enable editions;
alter user TO_BE_EDITIONED enable editions
*
ERROR at line 1:
ORA-38819: user TO_BE_EDITIONED owns one or more
objects whose type is editionable and that have
noneditioned dependent objects
330
331. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
u.name,
d.name,
d.namespace,
d.stime
from obj$ d,
dependency$ dep,
obj$ p,
user$ u
where d.obj# = dep.d_obj#
and p.obj# = dep.p_obj#
and d.remoteowner is null
and p.owner# = :1
and d.owner# = u.user#
and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and u.user#!= p.owner#)
or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))
331
332. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
u.name,
d.name, dba_dependencies
d.namespace,
d.stime
from obj$ d,
dependency$ dep,
obj$ p,
user$ u
where d.obj# = dep.d_obj#
and p.obj# = dep.p_obj#
and d.remoteowner is null
and p.owner# = :1
and d.owner# = u.user#
and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and u.user#!= p.owner#)
or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))
332
333. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
u.name,
d.name, dba_dependencies
d.namespace,
d.stime
from obj$ d,
dependency$ dep,
obj$ p,
user$ u object_type
where d.obj# = dep.d_obj#
and p.obj# = dep.p_obj#
and d.remoteowner is null
and p.owner# = :1
and d.owner# = u.user#
and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and u.user#!= p.owner#)
or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))
333
334. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
u.name,
d.name,
d.namespace,
d.stime
from obj$ d,
dependency$ dep,
obj$ p,
user$ u object_type
where d.obj# = dep.d_obj#
and
and
p.obj# = dep.p_obj#
d.remoteowner is null editions_enabled
and p.owner# = :1
and d.owner# = u.user#
and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and u.user#!= p.owner#)
or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))
334
335. select *
from DBA_DEPENDENCIES
where ( OWNER in ( SELECT username
from dba_users
where EDITIONS_ENABLED = 'N' )
OR TYPE NOT IN (
'VIEW','SYNONYM','PROCEDURE','FUNCTION'
,'PACKAGE','NON-EXISTENT','PACKAGE BODY'
,'TRIGGER','TYPE','TYPE BODY'
,'LIBRARY','ASSEMBLY')
)
and REFERENCED_OWNER = 'TO_BE_EDITIONED'
and TYPE IN (
'VIEW','SYNONYM','PROCEDURE','FUNCTION'
,'PACKAGE','NON-EXISTENT','PACKAGE BODY'
,'TRIGGER','TYPE','TYPE BODY'
,'LIBRARY','ASSEMBLY')
and REFERENCED_OWNER != OWNER
335
357. <apology>
The presentation author apologises
for the gratuitous use of family album
shots, but since his whole family
came to Melbourne for InSync,
he didn't have much choice.
<apology>
357