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 ...
随机推荐
- epoll LT/ET 深度剖析
EPOLL事件的两种模型: Level Triggered (LT) 水平触发 .socket接收缓冲区不为空 有数据可读 读事件一直触发 .socket发送缓冲区不满 可以继续写入数据 写事件一直触 ...
- php修改
做出一张表,点击登录后进入此表 然后多建立一个<td></td>用来增加一列操作 <h1>英雄联盟英雄表</h1> <table width= ...
- 基于Caffe的Large Margin Softmax Loss的实现(中)
小喵的唠叨话:前一篇博客,我们做完了L-Softmax的准备工作.而这一章,我们开始进行前馈的研究. 小喵博客: http://miaoerduo.com 博客原文: http://www.miao ...
- Android数据加密之Aes加密
前言: 项目中除了登陆,支付等接口采用rsa非对称加密,之外的采用aes对称加密,今天我们来认识一下aes加密. 其他几种加密方式: Android数据加密之Rsa加密 Android数据加密之Aes ...
- SQL Server-分页方式、ISNULL与COALESCE性能分析(八)
前言 上一节我们讲解了数据类型以及字符串中几个需要注意的地方,这节我们继续讲讲字符串行数同时也讲其他内容和穿插的内容,简短的内容,深入的讲解,Always to review the basics. ...
- JavaScript学习总结(四)——jQuery插件开发与发布
jQuery插件就是以jQuery库为基础衍生出来的库,jQuery插件的好处是封装功能,提高了代码的复用性,加快了开发速度,现在网络上开源的jQuery插件非常多,随着版本的不停迭代越来越稳定好用, ...
- 中文分词工具探析(二):Jieba
1. 前言 Jieba是由fxsjy大神开源的一款中文分词工具,一款属于工业界的分词工具--模型易用简单.代码清晰可读,推荐有志学习NLP或Python的读一下源码.与采用分词模型Bigram + H ...
- ASP.NET Core的Kestrel服务器
原文地址----Kestrel server for ASP.NET Core By Tom Dykstra, Chris Ross, and Stephen Halter Kestrel是一个基于l ...
- 【C#】给无窗口的进程发送消息
注:本文适用.net2.0+的winform程序 一个winform程序,我希望它不能多开(但是如何防多开不是本文要讲的),那么在用户启动第二个实例的时候,作为第二个实例来说,大概可以有这么几种做法: ...
- add-two-numbers
leetcode开篇~ 问题描述: You are given two linked lists representing two non-negative numbers. The digits a ...