72. 78
SQL> commit;
Commit complete.
SQL> select * from ORA$PTT_MY_TT;
select * from ORA$PTT_MY_TT
*
ERROR at line 1:
ORA-00942: table or view does not exist
78. SQL> create private temporary table MY_TT ( x int ) ;
ERROR at line 1:
ORA-00903: invalid table name
SQL> show parameter private
NAME TYPE VALUE
------------------------------- ----------- -----------
private_temp_table_prefix string ORA$PTT_
81. SQL> insert into t values ('Hello','There');
insert into t values ('Hello','There')
*
ERROR at line 1:
ORA-16000: database open for read-only access
112. 119
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
118. 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 /
120. 127
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
122. SQL> select deptno
2 listagg(job,',') within group ( order by job) as jobs
3 from scott.emp
4 group by deptno
5 order by 1;
DEPTNO JOBS
--------- --------------------------------------------------
10 CLERK,MANAGER,PRESIDENT
20 ANALYST,ANALYST,CLERK,CLERK,MANAGER
30 CLERK,MANAGER,SALESMAN,SALESMAN,SALESMAN,SALESMAN
124. SQL> select deptno
2 listagg(distinct job,',') within group ( order by job) as jobs
3 from scott.emp
4 group by deptno
5 order by 1;
DEPTNO JOBS
--------- --------------------------------------------------
10 CLERK,MANAGER,PRESIDENT
20 ANALYST,CLERK,MANAGER
30 CLERK,MANAGER,SALESMAN
132. 140
numeric TRIM
if x < lower return lower
if x > upper return upper
otherwise return x
133. SQL> create function clip
2 (lo number, x number, hi number)
3 return number is
4 begin
5 return least(greatest(x, lo), hi);
6 end;
7 /
134. SQL> create function clip
2 (lo number, x number, hi number)
3 return varchar2 SQL_MACRO(SCALAR) is
4 begin
5 return 'least(greatest(x, lo), hi)';
6 end;
7 /
140. SQL> CREATE FUNCTION budget(dept_no number)
2 RETURN varchar2 SQL_MACRO(TABLE) IS BEGIN
3 RETURN q'[
4 SELECT
5 d.deptno,
6 SUM(e.sal) budget,
7 count(e.empno) headcount,
8 count(e.mgr) mgr_headcount
9 FROM emp e, dept d
10 WHERE d.deptno = :dept_no
11 AND e.deptno = d.deptno
12 GROUP BY d.deptno]';
13 end;
141. SQL> WITH east_coast as
2 (SELECT deptno
3 FROM dept
4 WHERE loc = 'Boston'
5 )
6 SELECT *
7 FROM budget(east_coast);
158. SQL> select count(*) from emp, emp, emp,
2 ( select 1 from dual connect by level <= 50000 );
COUNT(*)
----------
27440000
Elapsed: 00:00:04.11
SQL> select count(*) from emp, emp, emp,
2 ( select 1 from dual connect by level <= 1000000 );
ERROR at line 1:
ORA-00040: active time limit exceeded - call aborted
Elapsed: 00:00:12.00
159. SQL> select count(*) from scott.emp, scott.emp, scott.emp,
2 ( select 1 from dual connect by level <= 100000 );
*
ERROR at line 1:
ORA-56955: quarantined plan used
160. SQL> desc V$SQL
Name Null? Type
---------------------- -------- ----------------------------
SQL_TEXT VARCHAR2(1000)
SQL_FULLTEXT CLOB
...
...
SQL_QUARANTINE VARCHAR2(128)
AVOIDED_EXECUTIONS NUMBER
194. 216
6) create true index (as invisible)
7) test execute each SQL for benefit
8) decide on index benefit for each SQL
9) SPM to avoid regressions
10) make new indexes visible
218. 244
We grant you a nonexclusive, nontransferable limited license to use the programs for:
(a) purposes of developing, prototyping and running your applications for your own internal data
processing operations;
(b) you may also distribute the programs with your applications;
(c) you may use the programs to provide third party demonstrations and training; and
d) you may copy and distribute the programs to your licensees provided that each such licensee
agrees to the terms of this Agreement
https://www.oracle.com/technetwork/licenses/db18c-express-license-5137264.html
219. 245
12 GB of user data
2 GB of database RAM
2 CPU threads
3 Pluggable Databases
232. oracle.com/gbtour
New Free Tier
Always Free
Oracle Cloud Infrastructure
Services you can use for unlimited time
30-Day Free Trial
Free credits you can use for more services
+
233. Autonomous
Database
2 x Databases
20GB Storage Each
Load
Balancing
10 Mbps
Bandwidth
Shape
Storage
2 x 50GB Block
10GB Object
10GB Archive
Compute
2 x VM
1GB Memory
Each