output

说明

从外部文件或键盘将数据导入数据库表中。

语法

output to filename
[ append ]
[ verbose ]
[ format output-format ]
[ escape character character ]
[ escapes { on | off}
[ delimited by string ]
[ quote string [ all ] ]
[ column widths (integer , . . . ) ]
[ hexidecimal { on | off | asis } ]
[ encoding encoding ]
output-format :
ascii | dbase | dbasell| dbaselll
| excel | fixed | foxpro | lotus | sql | xml  
encoding : string or identifier 

参数

示例

将 employee 表的内容放置在 ASCII 格式的文件中:

select *
from employee
go
output to employee.txt
format ASCII 

将 employee 表的内容放置在现有文件的末尾,同时还在此文件中包含有关查询的所有消息:

select *
from employee
go
output to employee.txt append verbose 

假定您需要导出包含嵌入式换行符的值。换行符的数值为 10,在 SQL 语句中,该值可表示为字符串“\x0a�±�£»Á¼°‘⁄ hexidecimal 设置为 on 的情况下执行下列语句:

select ‘line1 n x0aline2’
go
output to file.txt hexidecimal on 

您将得到一个文件,其中包含一行文本:

line10x0aline2 

但是,如果在 hexidecimal 设置为 off 的情况下执行同一语句,您将得到下列文本:

line1 n x0aline2 

最后,如果将 hexidecimal 设置为 asis,您将得到一个包含两行文本的文件:

line1
line2 

由于已导出的嵌入式换行符没有转换成两位数的十六进制形式,也没有使用任何前缀,因此在使用 asis 时获得两行。

用法

权限

任何用户都可以运行此命令。

副作用

在 Interactive SQL 中,“结果”选项卡仅显示当前查询的结果。所有先前的查询结果都替换为当前查询结果。

另请参见

input