You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除SQL脚本输出首行的换页(Form Feed)字符

Fixing Leading Form Feed (FF) in Oracle 10g SQL*Plus CSV Output

Hey Mark, I’ve dealt with this exact annoying FF character issue in Oracle 10g SQL*Plus before—nothing ruins a good CSV faster than a hidden control character messing up the first line! Let’s go through three reliable fixes tailored to your setup:

Solution 1: Adjust SQL*Plus Settings (Cleanest 10g-Specific Fix)

Oracle 10g’s set newpage 0 doesn’t fully eliminate the FF character like newer versions do. Update your script’s header with these extra settings to block it entirely:

-- Add these first to suppress FF and extra noise
set echo off
set verify off
set trimout on
set trimspool on
set newpage 0

-- Keep your original required settings
set pagesize 1000
set scan off
set feedback off
set linesize 3000
set heading off

Pro tip: Make sure all these set commands run before your spool command (if you’re using one) — SQL*Plus applies settings in the order they’re executed.

Solution 2: Strip FF via Unix Shell Post-Processing

If tweaking SQL settings doesn’t do the trick, clean up the output directly in your shell script. Use sed to remove the leading ASCII 12 (FF) character:

If you’re piping SQL*Plus output directly to a file:

sqlplus your_user/your_pass@your_db @your_script.sql | sed 's/^\x0c//' > final_output.csv

If you’re spooling inside the SQL script:

# Run the SQL script first
sqlplus your_user/your_pass@your_db @your_script.sql
# Clean up the spooled file in-place
sed -i 's/^\x0c//' your_spooled_file.csv

Note: For BSD/macOS systems, the sed in-place edit needs an empty string flag: sed -i '' 's/^\x0c//' your_spooled_file.csv.

Solution 3: Quick SQL Workaround (No Shell Changes Needed)

If you want to handle everything within your SQL script, add a blank prompt at the very top to overwrite the FF character:

-- Blank prompt to push FF to an unused line
prompt 

-- Rest of your set commands and query logic here
set pagesize 1000
...

This works because the FF gets attached to the blank prompt line, which won’t interfere with your actual CSV data.

内容的提问来源于stack exchange,提问作者Mark

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 10:02:34