informix-dbexport-dbimport

来源:互联网 发布:淘宝客服设置自动回复 编辑:程序博客网 时间:2024/05/15 08:09
/**************************************************************************************/
informix 的 导入导出


-- 1 分隔符设置(在使用了 双引号等 情况下,导入导出都需要设置)
   export DELIMIDENT=y


-- 2 导出需要 没有其他 数据库 连接存在 ,一般 对数据库重启后 立即运行导出


-- 3 导入前要删除同名的 数据库


-- 4 导入前要建立需要的 空间 dbspace,sbspace等


-- 5 onconfig.gbaseserver 参数文件的 相关参数 : 
-- 5.1 其中 sbspace 空间的参数 在 onconfig.gbaseserver 文件中设置,需要一致
SBSPACENAME sbspace 
SYSSBSPACENAME sbspace 


-- 5.2 换行支持 ALLOW_NEWLINE=1
-- 5.3 VPCLASS        jvp,num=1


/**************************************************************************************/
--1 当前连接数据库的 用户
[informix@localhost script]$ onstat -g sql


GBase 8t Database Server Version 12.10.FC4G1AEE -- On-Line -- Up 00:17:34 -- 1927212 Kbytes




Sess       SQL            Current            Iso Lock       SQL  ISAM F.E. 
Id         Stmt type      Database           Lvl Mode       ERR  ERR  Vers  Explain    
42         -              ifmis_jsx          CR  Not Wait   0    0    9.28  Off        
41         -              ifmis_jsx          CR  Not Wait   0    0    9.28  Off        
39         -              ifmis_jsx          CR  Not Wait   -217 0    9.28  Off        
38         -              ifmis_jsx          CR  Not Wait   0    0    9.28  Off      


--2 关闭数据库
[informix@localhost script]$ onmode -ky


--3 启动数据库 


[informix@localhost script]$ oninit -vy


--4 导出 
export DELIMIDENT=y


[informix@localhost script]$ dbexport  ifmis_jsx -c -ss -o /home/informix/script




--5 数据库 的 空间
[informix@localhost script]$ onstat -d


Dbspaces
address          number   flags      fchunk   nchunks  pgsize   flags    owner    name
499c7028         1        0x70001    1        1        2048     N  BA    informix rootdbs
4ad9c330         2        0x60001    2        1        8192     N  BA    informix ifmis_jsx
4ad9c560         3        0x42001    3        1        8192     N TBA    informix tmpdbs1
4ad9c9c0         5        0x68001    5        1        2048     N SBA    informix sbspace
 
4adab028         2      2      0          1250000    1053608               PO-B-- /home/informix/dbs/ifmis_jsx
 


Expanded chunk capacity mode: always


--6 为导入创建新的 空间
[informix@localhost script]$ 
cd /opt/dbs
touch ifmis_jsx  sbspace frag1 frag2 frag3
chmod 660 ifmis_jsx  sbspace frag1 frag2 frag3 


--6.1 dbspace
[informix@localhost script]$ onspaces -c -d ifmis_jsx -p /opt/dbs/ifmis_jsx -o 0 -s 2000000 -k 8k


[informix@localhost script]$ onspaces -c -d frag1 -p /opt/dbs/frag1 -o 0 -s 200000 -k 8k


[informix@localhost script]$ onspaces -c -d frag2 -p /opt/dbs/frag2 -o 0 -s 200000 -k 8k


[informix@localhost script]$ onspaces -c -d frag3 -p /opt/dbs/frag3 -o 0 -s 200000 -k 8k


--6.2 sbspace 大对象空间


[informix@localhost script]$ onspaces -c -S sbspace -p /opt/dbs/sbspace -o 0 -s 2000000 -k 8k


--7 更改 系统的 参数
--7.1 缺省default sbspace name 参数 
[informix@localhost script]$  vi onconfig.gbaseserver 
SBSPACENAME sbspace1
SYSSBSPACENAME sbspace1





SBSPACENAME sbspace 
SYSSBSPACENAME sbspace 


--7.2
[informix@localhost script]$  vi onconfig.gbaseserver 
ALLOW_NEWLINE =1


数据库实例级别修改配置参数,以支持回车换行写入。既在informix帐户$ONCONFIG文件中将 ALLOW_NEWLINE 设定为1
(默认为0:所有用户不支持写入换行回车)。但此参数修改需要重启数据库生效。


--7.3 增加环境变量 ( 解决分隔符和大写创建的对象问题 ),但是 和脚本 中 的  system "" 命令冲突
export DELIMIDENT=y




--7.4 guid
1.onconfig参数VPCLASS打开        
VPCLASS        jvp,num=1


2.将guid1.jar 程序传到INFORMIXDIR/extend/路径


3. execute procedure install_jar("file:$INFORMIXDIR/extend/guid1.jar", "guid1",0);




4. create function sys_guid() returns char(20)
        external name 'guid1:UUIDGenerator.getGuid()'
        language java;


--8 导入数据库
 
[informix@localhost script]$ dbimport ifmis_jsx -i /home/informix/script ifmis_jsx -c -l buffered -d ifmis_jsx


 
--9其他错误
--9.1 表的名字在 创建时用引号 大写字符创建  设置 export DELIMIDENT=y


create table "informix"."TMP_LZZ1" 
  (
    colname varchar(128)
  ) extent size 16 next size 32 lock mode page statchange 0;
*** prepare sqlobj
201 - A syntax error has occurred.


--9.2 取消下面的2行 
CREATE FUNCTION "informix".f11(per_cent INT)
RETURNING int;
DEFINE A INT;
LET A=10;
return a*10;
END FUNCTION;
DOCUMENT "USAGE: EXECUTE FUNCTION raise_prices (xxx)",
"xxx = percentage from 1 - 100"  WITH LISTING IN '/home/informix/awarn.txt';


--9.3 DELIMIDENT=y 相冲突 将双引号改为单引号 
CREATE PROCEDURE "informix".run_proc()
system "dbaccess ifmis_jsx /home/informix/run.sql";
system "dbaccess ifmis_jsx /home/informix/sql_table.sql";
end  PROCEDURE ;
*** prepare sqlobj
667 - Variable(dbaccess ifmis_jsx /home/informix/run.sql) not declared.


*** prepare sqlobj
667 - Variable(%Y-%m-%d) not declared.


if(TO_CHAR(NEW.DBVERSION,'%Y-%m-%d') ='2012-01-01') then


--9.4 guid 问题,见上面的 解决方法 


9799 - User Defined Routine (sys_guid) VP context switch failed.


--9.5 


create trigger "informix".tr_test2_update1 update of t2 on "informix"
    .test2
    for each row
        (
        execute procedure "informix".tr_test2_pro() with trigger 
    references );
*** execute sqlobj
8333 - Invalid invocation of the routine with referencing clause.


  ) extent size 16 next size 32 lock mode row;
*** execute sqlobj
310 - Table (sqlj.retained_jars) already exists in database.




--9.6
 
 create trigger "informix".trigger_guid_p$code_t_fund_level insert 
    on "informix".p$code_t_fund_level referencing new as new
    for each row
        (
        execute procedure "informix".p$code_t_fund_level_pro_guid() 
    with trigger references );
*** execute sqlobj
458 - Long transaction aborted.


12204 - RSAM error: Long transaction detected.


--9.7
*** prepare sqlobj
25807 - The fragment key for interval fragmentation must be a single column expression.
0 0