shell实现查询oracle数据库表,并写到本地txt文件
1、表结构
create table t_student(
id number(10) primary key,
name varchar2(50),
birthday date
); create sequence seq_t_student start with 1 increment by 1; insert into t_student values(seq_t_student.nextval,'张三',sysdate);
insert into t_student values(seq_t_student.nextval,'李四',to_date('1990-01-01 13:13:13','yyyy-mm-dd hh24:mi:ss'));
commit;
2、shell
#!/bin/bash
sqlplus -s centos/centos@win7orcl <<EOF >/ljxd/shell-demo/oracle/student.txt
set pages 0
set feed off
set heading off
set feedback off
set verify off
set linesize 1000
select t.id||'###'||t.name||'###'||to_char(t.birthday,'yyyy-mm-dd hh24:mi:ss') from t_student t;
EOF
3、分析
centos/centos@win7orcl #数据库客户端配置请参考http://www.cnblogs.com/crazyMyWay/articles/4371984.html
/ljxd/shell-demo/oracle/student.txt #为输出的文件
set pages 0 #从txt文本第一行开始写入
set feed off #...
set heading off #去掉表头写入
set feedback off #去掉最后一行空白行写入
set verify off #...
set linesize 1000 #每行只能1000个字符
4、测试命令
5、导出的结果文件如下:

shell实现查询oracle数据库表,并写到本地txt文件的更多相关文章
- C# 读取网络txt文件 并写在本地txt文件中
public void WriteStream() { try { stirng ImagesPath = ImagesPath + "\\2013-09-27.txt"; Htt ...
- Oracle 数据库表同步方法浅议
总结一下Oracle数据库表级别的复制同步 一.通过触发器进行表的复制 原理,是监听表上都某一字段进行的DML操作,然后得到DML操作的数据,重新在另一个表上执行DML操作. 优点: 简单,编写一个触 ...
- Oracle数据库表分区
一.Oracle数据库表分区概念和理解 1.1.已经存在的表没有方法可以直接转化为分区表. 1.2.不在分区字段上建立分区索引,在别的字段上建立索引相当于全局索引.效率 ...
- oracle数据库表中,插入数据的时候如何产生一个 字母+数字 编号?
Oracle 语句中“||”代表什么啊? oracle数据库表中,插入数据的时候如何产生一个 字母+数字 编号? 排序的话,用order by来处理即可.比如:cola123a234b999b335s ...
- 在oracle数据库表中没有添加rowid字段为什么会出现?
rowid 是 oracle 数据库表中的伪列, rowid 首先是一种数据类型,它唯一标识一条记录物理位置, 基于64位编码的18个字符显示.因为 rowid 是伪列, 所以并未真的存储在表中,但可 ...
- 查看Oracle数据库表空间大小(空闲、已使用),是否要增加表空间的数据文件
查看Oracle数据库表空间大小(空闲.已使用),是否要增加表空间的数据文件 1.查看表空间已经使用的百分比 Sql代码 select a.tablespace_name,a.bytes/1024/1 ...
- 使用PLSQL Developer和DbVisualizer、SQLDBx查询oracle数据库时出现乱码
使用PLSQL Developer和DbVisualizer查询oracle数据库时,出现查询数据中文乱码情况. 查看了一下数据库编码格式select * from v$nls_parameters; ...
- oracle数据库表空间追加数据库文件方法
oracle数据库表空间追加数据库文件方法 针对非大文件方式表空间,允许追加文件进行表空间的扩展,单个文件最大大小是32G 第一种方式:表空间增加数据文件 www.2cto.com 1 ...
- 查询oracle数据库,返回的数据是乱码。 PL/SQL正常。
查询oracle数据库,返回的数据是乱码. PL/SQL正常. 解决方案如下:
随机推荐
- [MySQL]快速解决"is marked as crashed and should be repaired"故障
具体报错如下: Table '.\Tablename\posts' is marked as crashed and should be repaired 提示说论坛的帖子表posts被标记有问题,需 ...
- light oj 1294 - Positive Negative Sign
1294 - Positive Negative Sign PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- springMVC学习笔记--初识springMVC
前一段时间由于项目的需要,接触了springMVC(这里主要是讲3.1版,以下内容也是围绕这个版本展开),发觉其MVC模式真的很强大,也简单易用,完全是基于注解实现其优雅的路径配置的.想想以前接手的项 ...
- 微软的.NET示例代码放在Github上了
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:微软的.NET示例代码放在Github上了.
- RichTextBox返回值标记不同颜色
在Button按钮下,将脚本的执行结果返回到richtextbox中: 如果返回值包含“failed",则该行标记为红色 .\Scripts\升级_ERP.ps1 | % { If ($_. ...
- 批处理:循环解压不同文件夹下的zip压缩包
结构如下 A文件夹: A1文件.zip A2文件.zip A3文件.zip B文件夹: B1文件.zip B2文件.zip B3文件.zip ...... 批处理文件:rezip.bat如下 @ech ...
- APUE习题5.x
5.4 下面的代码在一些机器上运行正确,而在另外一些机器运行时出错,解释问题所在? #include <stdio.h> int main( void ) { char c; while( ...
- NIO学习:buffer读入与写出(文件复制示例)
FileInputStream fInputStream=new FileInputStream(new File("/root/Desktop/testImage.jpg")); ...
- [翻译]Python with 语句
With语句是什么? Python's with statement provides a very convenient way of dealing with the situation wher ...
- oracle EBS中使用PLSQL提交"关闭离散"并发请求
declare l_request_id number; l_return_flag boolean; l_num_user_id number; l_num_resp_id number; l_nu ...