Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1567131
  • 博文数量: 201
  • 博客积分: 2812
  • 博客等级: 少校
  • 技术积分: 3029
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-18 18:28
个人简介

从事数据库工作多年,目前看好分布式NeSQL/HTAP数据库在企业客户市场的发展。未来的主要方向是——致力于 NewSQL/HTAP 数据库的推广普及。

文章存档

2016年(1)

2015年(8)

2014年(23)

2013年(50)

2012年(32)

2011年(87)

分类: Sybase

2012-10-31 11:13:35

  有时我们需要从IQ数据库中导出数据,供其他应用系统或数据库使用。为了实现这一功能,我们可以使用传统的BCP工具,也可以使用效率更高的Server端Export功能。本文将介绍这种功能的使用方法和注意事项。

   1. 使用方法

  通过下面的例子来说明使用方法:
     set temporary option temp_extract_row_delimiter = '\x0a';
     set temporary option temp_extract_column_delimiter = '|!';
     set temporary option temp_extract_null_as_empty = 'OFF';
     set temporary option temp_extract_append = 'OFF';
     set temporary option temp_extract_binary = 'OFF';
     set temporary option temp_extract_swap = 'OFF';
     set temporary option temp_extract_name1 = '/export/customer_2012.dat';
     set temporary option TEMP_EXTRACT_SIZE1='536870912' ;  --单位为KB
     
     select * from customer;

     set temporary option temp_extract_name1 = '';
      
  说明:上面的语句需要使用dbisql或dbisqlc执行。如果使用isql执行的话,需要改为
             
          set temporary option Escape_character = 'ON'
          go
     set temporary option temp_extract_row_delimiter = '\x0a'
     go
     set temporary option temp_extract_column_delimiter = '|!'
     go
     set temporary option temp_extract_null_as_empty = 'OFF'
     go
     set temporary option temp_extract_append = 'OFF'
     go
     set temporary option temp_extract_binary = 'OFF'
     go
     set temporary option temp_extract_swap = 'OFF'
     go
     set temporary option temp_extract_name1 = '/export/customer_2012.dat '
     go
     set temporary option TEMP_EXTRACT_SIZE1 = '536870912'
     go
     select * from customer
     go
     set temporary option temp_extract_name1 = ''
     go

   2. 注意事项

  (1) 使用Server端Export方法导出的数据存放在Server端所能访问到的OS文件系统的文件中。由于IQ具有数据压缩功能,当导出到文件之后数据将被解压。文件占用的空间大概是原来库内尺寸的2到3倍(根据数据的特点,有可能更多),因此为了存放导出的数据文件,文件系统空间应该充足。

    (2) Server端Export功能实际上是把select语句的结果集重定向到操作系统文件中,因此,我们可以灵活的编写select语句,从而实现灵活的数据导出。

    (3) 如果使用dbisql执行导出数据的sql脚本需要注意进行相关的设置:

       a. 对于IQ 12.7版本的dbisql,需要如下设置:

       需要执行之前在相应OS用户的home目录下编辑一个文件.isqlPreferences9(如果不存的话编辑一个)里面的内容应至少包括如下两项:
         printResultSetToConsole=2
         showMultipleResultSets=true

       b. 对于IQ 15.0、IQ 15.1、IQ 15.2版本,需要如下设置:

       需要执行之前在相应OS用户的home目录下修改或编辑一个文件.isqlPreferences11,下面是这个文件的一个示例,注意红色的地方:




(NULL)
Prompt
3
Off
false

2
0
5000000000
true
150
50 50 700 500
7
readWrite
asensitive
1
/home/sybiq/export.sql
'
0
On
1

28.42377260981912
ASCII
6267
Prompt
256
\
30
;
(SYSTEM)
graphicalOptimizer
1
ASCII
true
true
0
0
false
ODBC
,
/home/sybiq
1
On
true
0
0
true
Prompt
1
all


       c. 对于IQ 15.4版本,需要如下设置:

       需要在执行前,修改OS用户的home目录下的“.sybase/DBISQL 12.0.1”目录下的.isqlPreferences12_64或.isqlPreferences12_32文件中的相关选项为如下值:

1
2

阅读(4201) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~