日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

informix 外部表

發布時間:2024/1/1 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 informix 外部表 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/************************************************************************************/
informix 外部表
/************************************************************************************/
1 創建空間
touch llogdbs plogdbs tmpdbs1 tmpdbs2 test_01 test_02
chmod 660 *
onspaces -c -d plogdbs -o 0 -s 512000 -p /opt/83dbsnew/plogdbs
onspaces -c -d llogdbs -o 0 -s 2048000 -p /opt/83dbsnew/llogdbs


onspaces -c -d tmpdbs -o 0 -s 1024000 -p /opt/83dbsnew/tmpdbs1 -t -k 16
onspaces -a tmpdbs ?-p /opt/83dbsnew/tmpdbs2 -o 0 ?-s 1024000 ?


onspaces -c -d test -p /opt/83dbsnew/test_01 -o 0 -s 2048000 -k


2 添加物理日志
onparams -p -s 500000 -d plogdbs -y


3 添加邏輯日志
for i in {1..15} ; do onparams -a -d llogdbs -s 200000; done


4 刪除ROOTDBS 的 日志
1)連續執行7次
onmode –l ??


2) 執行手工CKPT
onmode –c ??


3) 刪除ROOTDBS 的 日志
$ for i in {1..6} ; do onparams ?-d -l $i -y ; done


?
5 創建數據庫
create database test in test with buffered log;


6 準備數據
create table t1(col1 int ,col2 varchar(20),col3 varchar(20),col4 varchar(20),col5 datetime year to second);


--添加數據存儲過程
drop procedure if exists sp_Add_data;?
create procedure sp_Add_data()
define ? ? ? i int;
define v_while int;
let i=0;
let v_while=0;
while v_while=0
let i=i+1;
if i=10000000 then
let v_while=1;
end if;
insert into t1 values(i,'col2'||i,'col3'||i,'col4'||i,sysdate);
end WHILE;
end procedure;


--添加數據
execute procedure sp_Add_data();


--設置隔離級別,讀數據
set isolation to dirty read;


--導出數據
unload to /home/informix/t1.unl select * from t1;
[informix@node1 ~]$ du -sh t1.unl?
616M t1.unl


7 使用外部表導入數據
drop table t1;
create table t1(col1 int ,col2 varchar(20),col3 varchar(20),col4 varchar(20),col5 datetime year to second);


1) 切割源文件:
$split -l 1000000 t1.unl


2)重命名數據文件,給外部表使用:
$j=1; for i in {a..j}; do ?mv "xa"$i t$j.unl; let j=j+1; done


3) 導入數據 shell腳本,具體如下:
# vi imp_unl.sh


/**********************************************************************************************/
#Author:xilai
#Version:0.8
#




usage()
{
cat <<!


Usage:
? ? ? ./imp_unl.sh ?-d dbname -t tabname -f /path/filename


!
exit 1
}




#[ $# -ne 6 ]&&usage


while getopts ?d:t:f: arg;do
? case $arg in
? ? d)
db=$OPTARG;;
? ? t)
tab=$OPTARG;;
? ? f)
fn=$OPTARG;;
? ? \?)
usage;;
? esac
done




[ ${db}t = t -o ${tab}t = t -o ${fn}t = t ]&&usage?


mkdir -p log
LOGFILE=log/${tab}_load.log


echo -e "Table:$tab\t Begin at $(date '+%F %T')" >> ${LOGFILE}


dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? drop table if exists ${tab}_ext;
? create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/home/informix/load/t%r(1..10).unl"),
? ? ?format "delimited",
? ? ?DELIMITER "|",
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);
? truncate table ${tab};
? alter table ${tab} type(raw);
!


onmode -c


bt=$(date +%s)


dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? set pdqpriority 100;
? set environment IFX_BATCHEDREAD_TABLE '1';
? insert into ${tab} select * from ${tab}_ext;
? alter table ${tab} type(standard);
? --drop table ${tab}_ext;
!
et=$(date +%s)
let t=et-bt
echo -e "Table:$tab\t Load Complete at $(date '+%F %T').\tUsed:$t s" >>${LOGFILE}


/**********************************************************************************************/


4) 腳本授權
# chmod +x imp_unl.sh


5)導入數據
數據導入的命令行如下:$time ./imp_unl.sh ?-d gdb(數據庫名稱) -t test_1g(導入對應的表名) -f abc(不需要調整)


# time ./imp_unl.sh ?-d test -t t1 -f abc?




6) 導出腳本
# vi exp_unl.sh
/**********************************************************************************************/
#Author:xilai
#Version:0.8
#




usage()
{
cat <<!


Usage:
? ? ? ./exp_unl.sh ?-d dbname -t tabname -f /path/filename


!
exit 1
}




#[ $# -ne 6 ]&&usage


while getopts ?d:t:f: arg;do
? case $arg in
? ? d)
db=$OPTARG;;
? ? t)
tab=$OPTARG;;
? ? f)
fn=$OPTARG;;
? ? \?)
usage;;
? esac
done




[ ${db}t = t -o ${tab}t = t -o ${fn}t = t ]&&usage?


mkdir -p log
LOGFILE=log/${tab}_load.log


echo -e "Table:$tab\t Begin at $(date '+%F %T')" >> ${LOGFILE}


dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? drop table if exists ${tab}_ext;
? create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/tmp/test%r(1..10).unl"),
? ? ?format "delimited",
? ? ?DELIMITER "|",
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);
? ?alter table ${tab} type(raw);
!
onmode -c


bt=$(date +%s)


dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? set pdqpriority 100;
? set environment IFX_BATCHEDREAD_TABLE '1';
? insert into ${tab}_ext select * from ${tab};
? --alter table ${tab} type(standard);
? --drop table ${tab}_ext;
!
et=$(date +%s)
let t=et-bt
echo -e "Table:$tab\t Load Complete at $(date '+%F %T').\tUsed:$t s" >>${LOGFILE}
/**********************************************************************************************/


7) 腳本授權
# chmod +x exp_unl.sh


8) 導出數據的命令行如下,數據被導出到/tmp/test*.unl文件中:
# time ./exp_unl.sh ?-d test -t t1 -f abc?




/**********************************************************************************************
外部表的格式
/**********************************************************************************************/


格式: including delimited and fixed ASCII, and IBM Informix internal.
1 including delimited ?
?create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/home/informix/load/t%r(1..10).unl"),
? ? ?format "delimited",
? ? ?DELIMITER "|",
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);


-rw-rw-rw- 1 informix informix 64560494 Jun 27 09:26 test9.unl


2 ?fixed ASCII
CREATE EXTERNAL TABLE ext_source_fix
(
empid CHAR(5) EXTERNAL CHAR(5),
empname VARCHAR(40) EXTERNAL CHAR(40),
empaddr VARCHAR(100) EXTERNAL CHAR(100)
)
USING(
FORMAT 'FIXED',
DATAFILES?
("DISK:/home/informix/load/fix.unl")
);




3 IBM Informix internal.(比 including delimited and fixed ASCII 格式 速度快, 文件SIZE 大 )
create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/tmp/test%r(1..10).unl"),
? ? ?format "INFORMIX",
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);


-rw-rw-rw- ?1 informix informix 75028800 Jun 27 09:33 test9.unl




/**********************************************************************************************/
外部表使用PIPE
使用PIPE 將一個實例中的表導入到另一個實例
/**********************************************************************************************/
1 創建PIPE
[informix@node1 load]$ mkfifo /home/informix/load/pipe1

[informix@node1 load]$ mknod /home/informix/load/pipe2 p


[informix@node1 load]$ ll
total 0
prw-rw-r-- 1 informix informix 0 Jun 27 11:03 pipe1
prw-rw-r-- 1 informix informix 0 Jun 27 11:03 pipe2


--使用多個PIPE
onmode -p +2 FIFO


2 創建數據表
源表:
CREATE TABLE source_data_table
(
empid CHAR(5),
empname VARCHAR(40),
empaddr VARCHAR(100)
);


insert into source_data_table values('111','aa1','tt1');
insert into source_data_table values('112','aa2','tt2');
insert into source_data_table values('113','aa3','tt3');
insert into source_data_table values('114','aa4','tt4');
insert into source_data_table values('115','aa5','tt5');
insert into source_data_table values('116','aa6','tt6');


--源表對應的外部表
CREATE EXTERNAL TABLE ext_source_data_table
(
empid CHAR(5),
empname VARCHAR(40),
empaddr VARCHAR(100)
)
USING
(DATAFILES
(
'PIPE:/home/informix/load/pipe1'
));


目標表:
CREATE TABLE destin_data_table
(
empid CHAR(5),
empname VARCHAR(40),
empaddr VARCHAR(100)
);


目標表對應的外部表:
CREATE EXTERNAL TABLE ext_destin_data_table
(
empid CHAR(5),
empname VARCHAR(40),
empaddr VARCHAR(100)
)
USING
(DATAFILES
(
'PIPE:/home/informix/load/pipe2'
));


redirects data from pipe1 to pipe2:
[informix@node1 ~]$ cat /home/informix/load/pipe1 > /home/informix/load/pipe2


--目標端:
> INSERT INTO destin_data_table SELECT * FROM ext_destin_data_table;


6 row(s) inserted.


Elapsed time: 7.404 sec
--源端
> INSERT INTO ext_source_data_table SELECT * FROM source_data_table;


6 row(s) inserted.


Elapsed time: 0.991 sec


/**********************************************************************************************/
使用多個PIPE
在一個機器上使用多個PIPE 會更加慢
/**********************************************************************************************/
1 創建PIPE
[informix@node1 load]$ ?for i in {1..2} ; do mkfifo /home/informix/load/pipe1_$i ; done
[informix@node1 load]$ ?for i in {1..2} ; do mkfifo /home/informix/load/pipe2_$i ; done


[informix@node1 load]$ ll
total 0
prw-rw-r-- 1 informix informix 0 Jun 27 14:45 pipe1_1
prw-rw-r-- 1 informix informix 0 Jun 27 14:45 pipe1_2
prw-rw-r-- 1 informix informix 0 Jun 27 14:45 pipe2_1
prw-rw-r-- 1 informix informix 0 Jun 27 14:45 pipe2_2
?
--使用多個PIPE
onmode -p +4 FIFO


2 創建數據表
源表:
create table t1(col1 int ,col2 varchar(20),col3 varchar(20),col4 varchar(20),col5 datetime year to second);
execute procedure sp_Add_data();




--源表對應的外部表
drop table ext_t1;
CREATE EXTERNAL TABLE ext_t1
SAMEAS t1
USING
(DATAFILES
(
'PIPE:/home/informix/load/pipe1_1',
'PIPE:/home/informix/load/pipe1_2'
));


目標表:
create table dest_t1(col1 int ,col2 varchar(20),col3 varchar(20),col4 varchar(20),col5 datetime year to second);




目標表對應的外部表:
drop table ext_dest_t1;
CREATE EXTERNAL TABLE ext_dest_t1
SAMEAS dest_t1
USING
(DATAFILES
(
'PIPE:/home/informix/load/pipe2_1',
'PIPE:/home/informix/load/pipe2_2'
));


redirects data from pipe1 to pipe2:
[informix@node1 ~]$ cat /home/informix/load/pipe1_1 > /home/informix/load/pipe2_1
[informix@node1 ~]$ cat /home/informix/load/pipe1_2 > /home/informix/load/pipe2_2


--目標端:(此結果是使用一對PIPE 的結果,使用2對PIPE 時間很長)
> INSERT INTO dest_t1 SELECT * FROM ext_dest_t1;


10000000 row(s) inserted.


?
--源端 (此結果是使用一對PIPE 的結果,使用2對PIPE 時間很長)
> INSERT INTO ext_t1 SELECT * FROM t1;


10000000 row(s) inserted.


Elapsed time: 1827.934 sec


[informix@node1 load]$ onstat -g ioq


GBase 8s Database Server Version 12.10.FC4G1AEE -- On-Line -- Up 00:19:48 -- 847684 Kbytes


AIO I/O queues:
q name/id ? ?len maxlen totalops ?dskread dskwrite ?dskcopy
?fifo ? 0 ? ? ?0 ? ? ?4 ? ? ? ?4 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
drda_dbg ? 0 ? ? ?0 ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
sqli_dbg ? 0 ? ? ?0 ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
? adt ? 0 ? ? ?0 ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
? msc ? 0 ? ? ?0 ? ? ?1 ? ? ? ?6 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
? aio ? 0 ? ? ?0 ? ? ?5 ? ? ?205 ? ? ? 25 ? ? ? ?0 ? ? ? ?0?
? pio ? 0 ? ? ?0 ? ? ?1 ? ? ? 48 ? ? ? ?0 ? ? ? 48 ? ? ? ?0?
? lio ? 0 ? ? ?0 ? ? ?1 ? ?15414 ? ? ? ?0 ? ?15414 ? ? ? ?0?
? gfd ? 3 ? ? ?0 ? ? 99 ? ? 2199 ? ? 1575 ? ? ?624 ? ? ? ?0?
? gfd ? 4 ? ? ?0 ? ?132 ? ?22396 ? ?12229 ? ?10167 ? ? ? ?0?
? gfd ? 5 ? ? ?0 ? ? ?1 ? ? ? ?6 ? ? ? ?5 ? ? ? ?1 ? ? ? ?0?
? gfd ? 6 ? ? ?0 ? ? ?4 ? ? ? ?5 ? ? ? ?1 ? ? ? ?4 ? ? ? ?0?
? gfd ? 7 ? ? ?0 ? ? ?2 ? ? ? ?3 ? ? ? ?1 ? ? ? ?2 ? ? ? ?0?
? gfd ? 8 ? ? ?0 ? ? ?1 ? ? 6758 ? ? 6757 ? ? ? ?1 ? ? ? ?0?
? gfd ?10 ? ? ?0 ? ? ?3 ? ? 5559 ? ? 5559 ? ? ? ?0 ? ? ? ?0?
gfdwq ?10 ? ? ?0 ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
? gfd ?12 ? ? ?0 ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0 ? ? ? ?0?
gfdwq ?12 ? ? ?0 ? ? ?4 ? ? 2788 ? ? ? ?0 ? ? 2788 ? ? ? ?0?


/**********************************************************************************************/
外部表使用FORMAT 'FIXED'
/**********************************************************************************************/
[informix@node1 load]$ finderr 26180
-26180 Missing external column type column-name.


The CREATE EXTERNAL TABLE statement is missing the external-column-
type information. This information is required for tables that describe
FIXED format files.


Add the column-type information and resubmit the statement.


26179: FIXED or DELIMITED columns must be external CHAR type empname.
Error in line 4
Near character position 40


1 創建數據表
CREATE TABLE source_fix
(
empid CHAR(5),
empname VARCHAR(40),
empaddr VARCHAR(100)
);


insert into source_fix values('111','aa1','tt1');
insert into source_fix values('112','aa2','tt2');
insert into source_fix values('113','aa3','tt3');
insert into source_fix values('114','aa4','tt4');
insert into source_fix values('115','aa5','tt5');
insert into source_fix values('116','aa6','tt6');


--對應的外部表
--format FIXED
CREATE EXTERNAL TABLE ext_source_fix
(
empid CHAR(5) EXTERNAL CHAR(5),
empname VARCHAR(40) EXTERNAL CHAR(40),
empaddr VARCHAR(100) EXTERNAL CHAR(100)
)
USING(
FORMAT 'FIXED',
DATAFILES?
("DISK:/home/informix/load/fix.unl")
);


?
> INSERT INTO ext_source_fix SELECT * FROM source_fix;


6 row(s) inserted.
[informix@node1 load]$ more fix.unl?
111 ?aa1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1
12 ?aa2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 11
3 ?aa3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 114
? aa4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 115?
?aa5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 116 ?
aa6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tt6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
[informix@node1 load]$ ?
-rw-rw-rw- 1 informix informix 870 Jun 27 15:41 fix.unl


--format delimited
?create external table ext_source_delimited sameas source_fix
? ?using
? ?(datafiles("DISK:/home/informix/load/fix_delimited.unl"),
? ? ?format "delimited",
? ? ?DELIMITER "|",
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);


> INSERT INTO ext_source_delimited SELECT * FROM source_fix;
-rw-rw-rw- 1 informix informix ?78 Jun 27 15:43 fix_delimited.unl
-rw-rw-rw- 1 informix informix 870 Jun 27 15:41 fix.unl
[informix@node1 load]$ more fix_delimited.unl?
111|aa1|tt1|
112|aa2|tt2|
113|aa3|tt3|
114|aa4|tt4|
115|aa5|tt5|
116|aa6|tt6|




/**********************************************************************************************/
外部表 3種 FORMAT 比較
/**********************************************************************************************/
--1 format INFORMIX
dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? drop table if exists ${tab}_ext;
? create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/tmp/test%r(1..10).unl"),
? ? ?format "INFORMIX", ? ??
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);
? ?alter table ${tab} type(raw);
!


[informix@node1 ~]$ time ./exp_unl.sh ?-d test -t t1 -f abc?


real 0m19.557s
user 0m0.041s
sys 0m0.011s


-rw-rw-rw- ? 1 informix informix 74959200 Jun 27 15:47 test10.unl
-rw-rw-rw- ? 1 informix informix 74959200 Jun 27 15:47 test1.unl
-rw-rw-rw- ? 1 informix informix 74959200 Jun 27 15:47 test2.unl
-rw-rw-rw- ? 1 informix informix 74959200 Jun 27 15:47 test3.unl
-rw-rw-rw- ? 1 informix informix 75019200 Jun 27 15:47 test4.unl
-rw-rw-rw- ? 1 informix informix 75028800 Jun 27 15:47 test5.unl
-rw-rw-rw- ? 1 informix informix 75028800 Jun 27 15:47 test6.unl
-rw-rw-rw- ? 1 informix informix 75028800 Jun 27 15:47 test7.unl
-rw-rw-rw- ? 1 informix informix 75028800 Jun 27 15:47 test8.unl
-rw-rw-rw- ? 1 informix informix 75028800 Jun 27 15:47 test9.unl


[informix@node1 ~]$ du -sh /tmp/test*
72M /tmp/test10.unl
72M /tmp/test1.unl
72M /tmp/test2.unl
72M /tmp/test3.unl
72M /tmp/test4.unl
72M /tmp/test5.unl
72M /tmp/test6.unl
72M /tmp/test7.unl
72M /tmp/test8.unl
72M /tmp/test9.unl






--2 format delimited
dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? drop table if exists ${tab}_ext;
? create external table ${tab}_ext sameas ${tab}
? ?using
? ?(datafiles("DISK:/tmp/test%r(1..10).unl"),
? ? ?format "delimited",
? ? ?DELIMITER "|",
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);
? ?alter table ${tab} type(raw);
!


[informix@node1 ~]$ time ./exp_unl.sh ?-d test -t t1 -f abc?


real 1m36.747s
user 0m0.040s
sys 0m0.017s


-rw-rw-rw- ?1 informix informix 64511159 Jun 27 15:51 test10.unl
-rw-rw-rw- ?1 informix informix 64560490 Jun 27 15:51 test1.unl
-rw-rw-rw- ?1 informix informix 64560470 Jun 27 15:51 test2.unl
-rw-rw-rw- ?1 informix informix 64560494 Jun 27 15:51 test3.unl
-rw-rw-rw- ?1 informix informix 64560494 Jun 27 15:51 test4.unl
-rw-rw-rw- ?1 informix informix 64560494 Jun 27 15:51 test5.unl
-rw-rw-rw- ?1 informix informix 64560494 Jun 27 15:51 test6.unl
-rw-rw-rw- ?1 informix informix 64560521 Jun 27 15:51 test7.unl
-rw-rw-rw- ?1 informix informix 64560501 Jun 27 15:51 test8.unl
-rw-rw-rw- ?1 informix informix 64560471 Jun 27 15:51 test9.unl
[informix@node1 tmp]$ du -sh test*
62M test10.unl
62M test1.unl
62M test2.unl
62M test3.unl
62M test4.unl
62M test5.unl
62M test6.unl
62M test7.unl
62M test8.unl
62M test9.unl






--3 format FIXED
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------


create table t1(col1 int ,col2 varchar(20),col3 varchar(20),col4 varchar(20),col5 datetime year to second);


drop table ext_EXTERNAL;
CREATE EXTERNAL TABLE ext_EXTERNAL
(
col1 int EXTERNAL CHAR(10),
col2 varchar(20) EXTERNAL CHAR(20),
col3 varchar(20) EXTERNAL CHAR(20),
col4 varchar(20) EXTERNAL CHAR(20),
col5 date ?EXTERNAL CHAR(10)
)
USING(
FORMAT 'FIXED',
DATAFILES?
("DISK:/home/informix/load/fix.unl")
);


insert into ext_EXTERNAL select * from t1;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------




dbaccess -e -m ${db}<< ! >> ${LOGFILE} 2>&1
? drop table if exists ${tab}_ext;
? create external table ${tab}_ext (
? col1 int EXTERNAL CHAR(10),
? col2 varchar(20) EXTERNAL CHAR(20),
? col3 varchar(20) EXTERNAL CHAR(20),
? col4 varchar(20) EXTERNAL CHAR(20),
? col5 date ?EXTERNAL CHAR(10)
? )
? ?using
? ?(datafiles("DISK:/tmp/test%r(1..10).unl"),
? ? ?format 'FIXED',
? ? ?express,
? ? ?rejectfile "/tmp/${tab}.err",
? ? ?maxerrors 10000
? ?);
? ?alter table ${tab} type(raw);
!


[informix@node1 ~]$ time ./exp_unl.sh ?-d test -t t1 -f abc?


real 0m23.887s
user 0m0.045s
sys 0m0.005s


-rw-rw-rw- 1 informix informix 79948000 Jun 27 16:03 test10.unl
-rw-rw-rw- 1 informix informix 79948000 Jun 27 16:03 test1.unl
-rw-rw-rw- 1 informix informix 79981360 Jun 27 16:03 test2.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test3.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test4.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test5.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test6.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test7.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test8.unl
-rw-rw-rw- 1 informix informix 80017520 Jun 27 16:03 test9.unl
[informix@node1 tmp]$ du -sh test*
77M test10.unl
77M test1.unl
77M test2.unl
77M test3.unl
77M test4.unl
77M test5.unl
77M test6.unl
77M test7.unl
77M test8.unl
77M test9.unl

總結

以上是生活随笔為你收集整理的informix 外部表的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。