spool命令
最近工作中,需对数据进行比对。在此之前,则需将数据导出。想到以前用过的spool命令,实验一番,分享如下:
需建SQL执行脚本,内容如下:
set feedback off --关掉行数显示
set heading off --关掉标题行
set termout off --关掉终端显示
set echo off --关掉回显
set pagesize 0 --去掉头顶的空行
set trims on --去掉空字符
spool /home/oracle/test.txt
select * from dept;
spool off
执行该脚本,最后/home/oracle/test.txt显示的内容即为表dept的数据:
50 IT CHINA
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 IT CHICAGO
40 OPERATIONS BOSTON
没有开头的SQL> select * from dept;和结尾的SQL> spool off
结合官档,总结一下SQL*Plus关于格式输出的命令:
SET ECHO {ON | OFF} Controls whether the START command lists each command in a script as the command is executed.
SET FEED[BACK] {6 | n | ON | OFF} Displays the number of records returned by a query when a query selects at least n records.
SET HEA[DING] {ON | OFF} Controls printing of column headings in reports.
SET LIN[ESIZE] {80 | n} Sets the total number of characters that SQL*Plus displays on one line before beginning a new line.
SET LONG {80 | n} Sets maximum width (in bytes) for displaying LONG, BLOB, BFILE, CLOB, NCLOB and XMLType values; and for copying LONG values.
SET PAGES[IZE] {14 | n} Sets the number of lines in each page.
SET TERM[OUT] {ON | OFF} Controls the display of output generated by commands executed from a script.
SET TI[ME] {ON | OFF} Controls the display of the current time.
SET TIMI[NG] {ON | OFF} Controls the display of timing statistics.
SET TRIMS[POOL] {ON | OFF} Determines whether SQL*Plus puts trailing blanks at the end of each spooled line.
SET TRIM[OUT] {ON | OFF} Determines whether SQL*Plus puts trailing blanks at the end of each displayed line.
SET VER[IFY] {ON | OFF} Controls whether SQL*Plus lists the text of a SQL statement or PL/SQL command before and after SQL*Plus
replaces substitution variables with values.
SET WRA[P] {ON | OFF} Controls whether SQL*Plus truncates the display of a SELECTed row if it is too long for the current line width
PS:关于SET ECHO语句,从定义上看有点费解,下面我们来看一下实验结果:
一、 SET ECHO OFF
1> 编辑SQL脚本t1.sql如下:
set echo off
select * from dept;
2> 执行该脚本

SQL> @t1.sql
DEPTNO DNAME LOC
---------- -------------- -------------
50 IT CHINA
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 IT CHICAGO
40 OPERATIONS BOSTON

二、 SET ECHO ON
1> 编辑SQL脚本t1.sql如下:
set echo on
select * from dept;
2> 执行该脚本

SQL> @t1.sql
SQL> select * from dept; DEPTNO DNAME LOC
---------- -------------- -------------
50 IT CHINA
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 IT CHICAGO
40 OPERATIONS BOSTON

spool命令的更多相关文章
- spool命令、创建一个表,创建而且copy表,查看别的用户下的表,rowid行地址 索引的时候使用,表的增删改查,删除表,oracle的回收站
1.spool命令 spool "D:\test.txt" spool off SQL> host cls 2.创建一个表 SQL> --条件(1):有创建 ...
- SPOOL 命令使用实例【oracle导出纯文本格式文件】
SPOOL 命令使用实例[oracle导出纯文本格式文件] SET echo off --在用start命令执行一个sql脚本时,是否显示脚本中正在执行的SQL语句: SET ...
- sqlplus 中spool命令的简单用法
spool基本格式: spool 路径+文件名 select col1||','||col2||','||col3||','||col4||'..' from tablename; spool off ...
- Oracle的spool命令
在控制台上使用spool 路径+文件名 命令可以将整个过程写入指定的文件中, 结束使用spool off 命令, 当执行spool off后文件中的内容才能看见; ed命令修改当前缓冲区的上一条命令;
- 使用spool命令从Oracle导出数据
公司的网站用的是Oracle数据库,最近要导出里面的数据,使用mysql数据库 spool D:\DB\{文件名}.sql set heading off; set echo off; set fee ...
- Oracle中spool命令实现的两种方法比较
---恢复内容开始--- 要输出符合要求格式的数据文件只需在select时用字符连接来规范格式.比如有如下表 SQL>; select id,username,password from myu ...
- Linux:spool命令
格式调整有以下参数: set echo on/off--是否显示脚本中的需要执行的命令 set feedback on/off--是否显示 select 结果之后返回多少行的提示 set linesi ...
- Oracle数据库存量数据抽取使用spool控制命令
spool是oracle sqlplus提供的一个控制命令.可以利用spool和select语句的组合动态生成一些失去了脚本或者一些数据. 1.spool作用: 在sqlplus中用来保存或打印查询 ...
- Oracle sqlplus设置显示格式命令详解
/ 运行 SQL 缓冲区 ? [关键词] 对关键词提供 SQL 帮助 @[@] [文件名] [参数列表] 通过指定的参数,运行指定的命令文件 ACC[EPT] 变量 [DEF[AULT] 值] [PR ...
随机推荐
- CocoaPods 1.1.0上传遇到swift问题
更新时间: 2016-11-25 1.出现如下信息: Conn keep-alive Updating spec repo `master` - Data URL: https://raw.githu ...
- iOS--碎片知识锦集
知识锦集day01 1.UIView的两个方法: sizeThatFits和 sizeToFit 官方文档上说: - (CGSize)sizeThatFits:(CGSize)size; // ...
- 设计模式之合成/聚合利用原则(CARP)
一.概念 CARP:CompositionAggregation Principle 合成聚合复用原则,尽量使用合成/聚合,尽量不使用类继承.合成聚合是“has a”的关系,而继承是“is a”的 ...
- JS原生第三篇 (帅哥)
1.1 数 组 1. 数组 看电影 电影院 座位 大的变量 里面可以放很多的值 var arr = [1,3,57]; var ar = new Array(); ...
- c#官方推荐md5通用加密类
/// <summary> /// MD5加密 /// </summary> /// <param name="input">需要加密的字符串& ...
- 制作自己的MVC框架(三)——应用
一.数据库操作 目前封装了两种数据库,“MongoDB”和“MySQL”,用到了一次接口“IDatabase.php”. namespace library\db; interface IDataba ...
- Java 哈希表运用-LeetCode 1 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- TCP四步挥手的各种状态转换图
对于TCP四步挥手时的各种状态转换,网上有很多资料.但是有很多描述不是很容易理解,甚至是描述错误,不如这篇文章里http://www.cnblogs.com/Jessy/p/3535612.html# ...
- CSS知识总结(六)
CSS常用样式 4.段落样式 1)行高 控制段落内每行高度 line-height : normal | length 例子 源代码: /* CSS代码 */ .normal{ line-height ...
- 大话keepalive
大话keepalive 我们说到keepalive的时候,需要先明确一点,这个keepalive说的是tcp的还是http的. tcp的keepalive是侧重在保持客户端和服务端的连接,一方会不定期 ...