当前位置:数据库 > SQLServer >>

Sqlplus输出explain plan的内容

Sqlplus输出explain plan的内容
 
大家都知道,在pl/sql中按F5,在sql developer中按F6可以查看sql执行计划,但是想把这些信息详细显示出来,则需要使用以下命令。
 
set autotrace traceonly explain
 
可以在sqlplus的窗口界面中使用该命令,再跟上对应的sql即可,但是这样想把结果复制出来比较费劲,鼠标在里面无法滚动。只能一点点拖动去选择。
 
Java代码  
set autotrace traceonly explain  
SELECT distinct t.* from (WITH Accts AS(select ccd_id.id_number AS ID_PASSPORT,ccd_cust.long_name AS longName,ccd_cust.chinese_name AS chineseName,'ADSR' AS source_system,cust.account_id AS ACCOUNT_ID,ccd_id.is_primary AS is_primary, '-' AS contractPhone, '-' AS benefOwerName, '-' AS benefOwerId,'-' AS guaName, '-' AS guaIdPassport, '-' AS dirName, '-' AS dirIdPassport from sds_ccd_id ccd_id join sds_customer_account cust on (cust.id_passport=ccd_id.id_number or cust.id_passport_2=ccd_id.id_number)join sds_ccd_customer ccd_cust on ccd_cust.id = ccd_id.ccd_ref JOIN SCS_COMPANY_GROUP CP  ON cp.id= cust.comp_grp_id  WHERE cp.comp_grp_id='SHK'  AND cust.account_id like '05228303' )SELECT accts.* FROM Accts accts )t;  
 
后面发现,oracle有另外一个东西可以用,那就是sqlplus worksheet.
开始->程序->Oracle-OraHome81->database Administration->SQLPLUS Worksheet
输入用户名,密码,连接字符,登录后
 
在窗口中输入以上sql脚本,即可,执行结果会显示在窗口下方,则可以很方便 的复制出来,如果想清除结果,则在edit下选择clear all。
 
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,