[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型別
- Oracle 10G 新特性--SQLPLUS的改進Oracle 10gSQL
- sqlplus與空行.txtSQL
- Oracle 12C 新特性之 sqlplus檢視History命令OracleSQL
- Oracle 12cR2中的ADG會話保留特性Oracle會話
- [20181225]12CR2 SQL Plan Directives.txtSQL
- 新特性
- Oracle11新特性——PLSQL新特性(七)OracleSQL
- Oracle11新特性——PLSQL新特性(六)OracleSQL
- Oracle11新特性——PLSQL新特性(五)OracleSQL
- Oracle11新特性——PLSQL新特性(四)OracleSQL
- Oracle11新特性——PLSQL新特性(三)OracleSQL
- Oracle11新特性——PLSQL新特性(二)OracleSQL
- Oracle11新特性——PLSQL新特性(一)OracleSQL
- [20140218]12c 新特性heat map.txt
- [20130808]12c新特性Temporary undo.txt
- [20131017]11G下truncate的新特性.txt
- [20230323]sqlplus #.txtSQL
- 【ORACLE新特性】11G 分割槽新特性Oracle
- React 新特性React
- 新特性介面
- 新特性方面
- Oracle 12C R2-新特性-SQLPLUS提供檢視歷史命令的功能OracleSQL
- [20190718]12c rman新特性 表恢復.txt
- [20190524]sqlplus 與輸出&.txtSQL
- [20170506]fetch sqlplus arraysize.txtSQL
- [20170617]vim中呼叫sqlplus.txtSQL
- [20190311]12cR2 Advanced index compression.txtIndex
- [20190720]12cR2顯示執行計劃.txt
- [20181007]12cR2 Using SQL Patch.txtSQL
- [20211104]12cR2 new index usage tracking.txtIndex
- 10G新特性筆記之安裝新特性筆記
- Servlet 3.0 新特性Servlet
- Go 1.13 新特性Go
- Java 11新特性Java
- PHP 7.4 新特性PHP
- Java 17新特性Java
- Prometheus 2.21.0 新特性Prometheus