[20181014]12cR2 sqlplus新特性.txt
[20181014]12cR2 sqlplus新特性.txt
--//前幾天講了SET FEEDBACK ONLY.在接著介紹另外幾個新特性.
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
2.command history:
--//12cR2支援命令歷史.可以顯示過去執行的命令調入重複執行:
SCOTT@test01p> set history 10
SCOTT@test01p> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> select sysdate from dual ;
SYSDATE
-------------------
2018-10-14 20:28:06
SCOTT@test01p> history
1 select * from dept where deptno=10;
2 select sysdate from dual ;
SCOTT@test01p> history 1 run
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@test01p> history 2 edit
--//編輯後放入第3位置.
SCOTT@test01p> history
1 select * from dept where deptno=10;
2 select sysdate from dual ;
3 select user from dual ;
SCOTT@test01p> history 3 run
USER
--------------------
SCOTT
SCOTT@test01p> history clear
SCOTT@test01p> history
SP2-1651: History list is empty.
3.12cR2支援變數定義以及直接賦值,前面版本不行:
SCOTT@test01p> variable a number ;
SCOTT@test01p> exec :a := 10;
PL/SQL procedure successfully completed.
--//12cR2可以直接賦值:
SCOTT@test01p> variable b number = 20;
--//注意這裡賦值沒有冒號在等號前面.orcle的語法太不統一.
SCOTT@test01p> print b
B
----------
20
SCOTT@test01p> print :b
B
----------
20
SCOTT@test01p> select * from dept where deptno = :b ;
DEPTNO DNAME LOC
---------- -------------------- -------------
20 RESEARCH DALLAS
4.Statement caching:
--//Statement caching有點像軟軟解析.
SCOTT@test01p> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
183 5778 5224:5288 DEDICATED 4932 62 13 alter system kill session '183,5778' immediate;
variable b number = 20;
Select * from dept where deptno = :b ;
Select * from dept where deptno = :b ;
--//透過查詢執行計劃,確定sql_id=2b073tss4h1f3.
SCOTT@test01p> select sql_id,executions,parse_calls,sql_text from v$sql where sql_id='2b073tss4h1f3';
SQL_ID EXECUTIONS PARSE_CALLS SQL_TEXT
------------- ---------- ----------- ------------------------------------------------------------
2b073tss4h1f3 2 2 Select * from dept where deptno = :b
--//執行2次,分析2次.
--//如果採用Statement caching
--//sesson 1:
set statementcache 100
variable c number = 10;
select * from dept where deptno = :c ;
select * from dept where deptno = :c ;
select sysdate from dual;
--//透過查詢執行計劃,確定sql_id='abzxwsyzmsu8h',另外開啟會話,登入cdb:
--//sesson 2:
SYS@test> select sql_id,executions,parse_calls,sql_text from v$sql where sql_id='abzxwsyzmsu8h';
SQL_ID EXECUTIONS PARSE_CALLS SQL_TEXT
------------- ---------- ----------- ------------------------------------------------------------
abzxwsyzmsu8h 2 1 select * from dept where deptno = :c
--//執行2次,分析1次.
SYS@test> @ sharepool/shp4 abzxwsyzmsu8h 0
TEXT KGLHDADR KGLHDPAR C40 KGLHDLMD KGLHDPMD KGLHDIVC KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000007FF11BBEA90 000007FF00093CA0 select * from dept where deptno = :c 1 0 0 000007FF11B96238 000007FF13353C48 4032 16200 3190 23422 23422 3208407312 abzxwsyzmsu8h 0
父遊標控制程式碼地址 000007FF00093CA0 000007FF00093CA0 select * from dept where deptno = :c 1 0 0 000007FF132EB0B0 00 4072 0 0 4072 4072 3208407312 abzxwsyzmsu8h 65535
--//KGLHDLMD=1.session 1最後執行的是select sysdate from dual;
--//session 1:
SCOTT@test01p> variable c number = 30;
SCOTT@test01p> select * from dept where deptno = :c ;
DEPTNO DNAME LOC
---------- -------------------- -------------
30 SALES CHICAGO
SCOTT@test01p> variable c number = 30;
SCOTT@test01p> select * from dept where deptno = :c ;
DEPTNO DNAME LOC
---------- -------------------- -------------
30 SALES CHICAGO
SYS@test> select sql_id,executions,parse_calls,sql_text from v$sql where sql_id='abzxwsyzmsu8h';
SQL_ID EXECUTIONS PARSE_CALLS SQL_TEXT
------------- ---------- ----------- ------------------------------------------------------------
abzxwsyzmsu8h 3 1 select * from dept where deptno = :c
--//執行3次,分析1次.
5.支援CSV資料格式顯示:
SCOTT@test01p> set markup csv on
SCOTT@test01p> select * from dept;
"DEPTNO","DNAME","LOC"
10,"ACCOUNTING","NEW YORK"
20,"RESEARCH","DALLAS"
30,"SALES","CHICAGO"
40,"OPERATIONS","BOSTON"
SCOTT@test01p> set markup csv on delimiter '|'
SCOTT@test01p> select * from dept;
"DEPTNO"|"DNAME"|"LOC"
10|"ACCOUNTING"|"NEW YORK"
20|"RESEARCH"|"DALLAS"
30|"SALES"|"CHICAGO"
40|"OPERATIONS"|"BOSTON"
SCOTT@test01p> set markup csv on delimiter '|' quote off
SCOTT@test01p> select * from dept;
DEPTNO|DNAME|LOC
10|ACCOUNTING|NEW YORK
20|RESEARCH|DALLAS
30|SALES|CHICAGO
40|OPERATIONS|BOSTON
SCOTT@test01p> set markup csv off
SCOTT@test01p> select * from dept;
DEPTNO DNAME LOC
---------- -------------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
6.我自己還有一個疑問,如果使用它連線低版本的資料庫,這些特性還能用嗎?
--//上班在更新自己的機器工作環境,看看是否生效.估計不行.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2216326/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20181014]12Cr2 impdp使用NETWORK_LINK支援LONG欄位型別.txt型別
- [20230323]sqlplus #.txtSQL
- [20190215]sqlplus set arraysize.txtSQL
- [20190524]sqlplus 與輸出&.txtSQL
- [20190530]sqlplus preliminary connection.txtSQL
- [20211125]sqlplus生成html格式.txtSQLHTML
- [20211108]sqlplus管道過濾.txtSQL
- [20211123]sqlplus @與@@的區別.txtSQL
- [20221203]sqlplus set trimspool 問題.txtSQL
- [20230417]sqlplus warpped word_warp.txtSQL
- [20221202]sqlplus set trimout 問題.txtSQL
- [20190311]12cR2 Advanced index compression.txtIndex
- [20181007]12cR2 Using SQL Patch.txtSQL
- [20190720]12CR2 max_idle_time.txt
- [20181225]12CR2 SQL Plan Directives.txtSQL
- [20180510]sqlplus array 和 opifch2.txtSQL
- [20191104]sqlplus 管道檔案 過濾.txtSQL
- [20190720]sqlplus 與輸出& 2.txtSQL
- [20211220]sqlplus簡單計算器.txtSQL
- [20211108]sqlplus 本地登入緩慢.txtSQL
- [20210119]sqlplus 12c LOBPREFETCH.txtSQL
- [20181007]12cR2 Using SQL Patch 2.txtSQL
- [20211104]12cR2 new index usage tracking.txtIndex
- [20190108]rlwrap sqlplus tee相關問題.txtSQL
- [20181122]18c sqlplus set linesize.txtSQL
- [20181207]sqlplus下顯示資料精度.txtSQL
- [20180813]sqlplus arraysize設定與SDU.txtSQL
- [20241112]無法理解sqlplus的輸出.txtSQL
- [20241013]sqlplus spool與檔案覆蓋.txtSQL
- [20190718]12c rman新特性 表恢復.txt
- [20190720]12cR2顯示執行計劃.txt
- [20190721]12CR2 max_idle_time 2.txt
- [20231103]sqlplus column new_value old_value.txtSQL
- [20211220]記錄使用sqlplus的小問題.txtSQL
- [20210722]sqlplus下show recycebin的小問題.txtSQL
- [20230303]sqlplus column new_value old_value.txtSQL
- [20181109]12cR2 的pre_page_sga引數.txt
- [20181109]12c sqlplus rowprefetch引數5.txtSQL