sqlplus 環境下部分set 命令
由於業務需要匯出單個欄位的少量資料,設定了指令碼來執行,但是結果總是回顯在螢幕上,而導致不合適。現將正確的格式的指令碼介紹一下。
剛開始自己的在linux執行的指令碼中沒有set trimspool on 這一設定,導致在linux下有結果回顯,而在windows下則符合要求
===============windows=============
--test.sql 檔案內容
set echo off 不顯示指令碼中的每個sql命令
set feedback off 禁止回顯sql命令處理的記錄條數(預設為 on)
set term off 禁止顯示指令碼中命令的執行結果(預設為on)
set heading off 禁止輸出標題(預設為on)
set pagesize 0 禁止輸出分頁
set linesize 1000 設定每行的字元輸出個數為1000,放置換行。
set trimout on 去除標準輸出每行的行尾空格 預設為off
set trimspool on 去除spool 輸出結果中每行的結尾空格 預設為off
spool d:\im_user.txt
select * from t where rownum <50;
--select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set feedback on
set echo on
exit;
C:\Users\aaaa>sqlplus yang/yang
SQL*Plus: Release 11.1.0.6.0 - Production on 星期三 3月 9 16:35:17 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
yang@ORACL> @d:\test.sql
yang@ORACL> exit;
================linux=================
#!/bin/sh
#created by yangql @2011-03-09
#parameters
ora_user=aliim
ora_passwd=aliim
sqlplus -s ${ora_user}/${ora_passwd} <set echo off
set feedback off
set term off
set heading off
spool /tmp/im_user.txt
select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set echo on
set feedback on
exit;
EOF
"get_im_user.sh" 20 lines, 407 characters written
oracle@dba-host1:/tmp>./get_im_user.sh
34607
74158
02561
82517
40445
85825
04801
65546
45715
b40384
73865
b52708
剛開始自己的在linux執行的指令碼中沒有set trimspool on 這一設定,導致在linux下有結果回顯,而在windows下則符合要求
===============windows=============
--test.sql 檔案內容
set echo off 不顯示指令碼中的每個sql命令
set feedback off 禁止回顯sql命令處理的記錄條數(預設為 on)
set term off 禁止顯示指令碼中命令的執行結果(預設為on)
set heading off 禁止輸出標題(預設為on)
set pagesize 0 禁止輸出分頁
set linesize 1000 設定每行的字元輸出個數為1000,放置換行。
set trimout on 去除標準輸出每行的行尾空格 預設為off
set trimspool on 去除spool 輸出結果中每行的結尾空格 預設為off
spool d:\im_user.txt
select * from t where rownum <50;
--select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set feedback on
set echo on
exit;
C:\Users\aaaa>sqlplus yang/yang
SQL*Plus: Release 11.1.0.6.0 - Production on 星期三 3月 9 16:35:17 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
yang@ORACL> @d:\test.sql
yang@ORACL> exit;
================linux=================
#!/bin/sh
#created by yangql @2011-03-09
#parameters
ora_user=aliim
ora_passwd=aliim
sqlplus -s ${ora_user}/${ora_passwd} <
set feedback off
set term off
set heading off
spool /tmp/im_user.txt
select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set echo on
set feedback on
exit;
EOF
"get_im_user.sh" 20 lines, 407 characters written
oracle@dba-host1:/tmp>./get_im_user.sh
34607
74158
02561
82517
40445
85825
04801
65546
45715
b40384
73865
b52708
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-688864/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- GTID環境下mysqldump set-gtid-purged取值MySql
- [20190215]sqlplus set arraysize.txtSQL
- 【學習】SQL基礎-009-sqlplus環境SQL
- [20221203]sqlplus set trimspool 問題.txtSQL
- [20221202]sqlplus set trimout 問題.txtSQL
- linux環境下sqlplus sys/sys@ORCL as sysdba報錯 ORA-01031: insufficient privilegesLinuxSQL
- 常用環境Docker命令Docker
- [20181122]18c sqlplus set linesize.txtSQL
- oracle系列(一)sqlplus命令OracleSQL
- linux執行環境&命令Linux
- Windows環境下的Nginx環境搭建WindowsNginx
- Windows 環境下 Python 環境安裝WindowsPython
- window環境下testlink環境搭建(xammp)
- MongoDB副本集replica set (二)--副本集環境搭建MongoDB
- SEEDLab —— 環境變數與 Set-UID 實驗變數UI
- LibOpenCM3(一) Linux下命令列開發環境配置Linux命令列開發環境
- 以太坊-Win環境下remix環境搭建REM
- windows環境telnet傳送命令Windows
- oracle sqlplus 常用命令OracleSQL
- Mac環境下MySQL的安裝和基本命令的使用MacMySql
- python下多環境開發(虛擬環境)Python
- ubuntu環境下搭建以太坊開發環境Ubuntu開發環境
- MAC環境下PHP開發除錯環境搭建MacPHP除錯
- linux或者CentOS環境下安裝.NET Core環境LinuxCentOS
- windows環境安裝nc(netcat)命令Windows
- win10環境下jdk1.8的安裝和環境配置(javac不是內部或者外部命令)Win10JDKJava
- Windows 下搭建 lnmp 環境WindowsLNMP
- Maven環境下MyBatisGenerator 配置MavenMyBatis
- Windows 下 Laravel 環境配置WindowsLaravel
- Centos下搭建golang環境CentOSGolang
- linux下配置java環境LinuxJava
- docker下LNMP環境搭建DockerLNMP
- mac 下搭建flutter環境MacFlutter
- windows下搭建lisp環境WindowsLisp
- CentOS下Ant環境配置CentOS
- set\list\map部分原始碼解析原始碼
- 在Ubuntu環境下用gcc命令執行c程式以及Makefile編譯UbuntuGCC程式編譯
- win 命令列 設定環境變數命令列變數
- Django入門指南-第1部分(環境搭建)Django