use*_*176 4 unix oracle bash import export
假设我有带有列的表 A
col1 col2 col3 col4
-------------------
sajal singh 28 IND
hello how are you
Run Code Online (Sandbox Code Playgroud)
我想将数据导出到一个平面文件中,列之间没有空格或制表符所以输出应该是
cat dump
sajalsingh28IND
hellohowareyou
Run Code Online (Sandbox Code Playgroud)
我尝试过什么。我写了一个脚本
#!/usr/bin/bash
#the file where sql output will go
OUT=report.txt
>$OUT
DESC=desc.txt
>$DESC
sqlplus -s "xxx/xxx@xxx" << END_SQL > /dev/null
set pages 0
set feedback off
set heading off
set trimspool off
set termout off
set verify off
set wrap off
SPOOL $DESC
Select * from table_name;
SPOOL OFF
END_SQL
Run Code Online (Sandbox Code Playgroud)
但我得到多行中一行的输出,并且带有制表符/空格
谢谢
如果您已有 CSV 转储,则可以运行以下命令:
awk 'BEGIN{FS=",";OFS=""}{$1=$1}1' csv.dump > new.dump
Run Code Online (Sandbox Code Playgroud)
SET HEADING OFF
SET FEEDBACK OFF
SPOOL $DESC
SELECT col1 ||''|| col2 ||''|| col3 FROM table_name;
SPOOL OFF;
Run Code Online (Sandbox Code Playgroud)