标签:sha this set convert case 函数导出 not sql cti
yum install perl-DBI perl-DBD-Pg perl-ExtUtils-MakeMaker gcc wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.74.tar.gz tar -zxvf DBD-Oracle-1.74.tar.gz cd DBD-Oracle-1.74 source /home/oracle/.bash_profile perl Makefile.PL -l make make install
2.安装 ora2pg包
unzip ora2pg-17.4.zip cd ora2pg-17.4 perl Makefile.PL make make install /usr/local/bin/ora2pg -v --默认安装在/usr/local/bin/目录下;版本为v17.4。 Ora2Pg v17.4
/etc/ora2pg/ora2pg.conf ORACLE_HOME /u01/app/oracle #This directive is used to set the data source name in the form standard DBI DSN ORACLE_DSN dbi:Oracle:ora229 ORACLE_USER lottu ORACLE_PWD li0924 LOGFILE /tmp/Ora2Pg.log SCHEMA LOTTU TYPE TABLE INSERT ALLOW ORATAB OUTPUT lottu01.sql [root@sdserver40_222 ~]# ora2pg -c /etc/ora2pg/ora2pg.conf [========================>] 1/1 tables (100.0%) end of scanning. [> ] 0/1 tables (0.0%) end of scanning. [========================>] 1/1 tables (100.0%) end of table export. [====> ] 1/6 rows (16.7%) Table ORATAB (1 recs/sec) [========================>] 6/6 rows (100.0%) on total estimated data (1 sec., avg: 6 recs/sec) [root@sdserver40_222 ~]# cat lottu01.sql -- Generated by Ora2Pg, the Oracle database Schema converter, version 17.4 -- Copyright 2000-2016 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:Oracle:ora229 SET client_encoding TO ‘UTF8‘; \set ON_ERROR_STOP ON CREATE TABLE oratab ( id bigint, name varchar(20) ) ; -- Generated by Ora2Pg, the Oracle database Schema converter, version 17.4 -- Copyright 2000-2016 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:Oracle:ora229 SET client_encoding TO ‘UTF8‘; \set ON_ERROR_STOP ON BEGIN; INSERT INTO oratab (id,name) VALUES (1001,E‘li0924‘); ALTER SEQUENCE IF EXISTS ggs_marker_seq RESTART WITH 7117; ALTER SEQUENCE IF EXISTS ggs_ddl_seq RESTART WITH 7117; COMMIT
解释:
[root@sdserver40_222 ~]# ora2pg -c /etc/ora2pg/ora2pg.conf [========================>] 1/1 tables (100.0%) end of scanning. [========================>] 1/1 tables (100.0%) end of table export. [root@sdserver40_222 ~]# cat lottu02.sql -- Generated by Ora2Pg, the Oracle database Schema converter, version 17.4 -- Copyright 2000-2016 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:Oracle:ora229 SET client_encoding TO ‘UTF8‘; \set ON_ERROR_STOP ON CREATE FOREIGN TABLE oratab ( id bigint, name varchar(20) ) SERVER orcl OPTIONS(schema ‘LOTTU‘, table ‘ORATAB‘);
3. Modifying object structure
[root@sdserver40_222 ~]# cat /etc/ora2pg/ora2pg.conf ORACLE_HOME /u01/app/oracle #This directive is used to set the data source name in the form standard DBI DSN ORACLE_DSN dbi:Oracle:ora229 ORACLE_USER lottu ORACLE_PWD li0924 LOGFILE /tmp/Ora2Pg.log SCHEMA LOTTU TYPE TABLE ALLOW ORATAB REPLACE_TABLES ORATAB:LOTTU01 MODIFY_TYPE ORATAB:ID:INT,ORATAB:NAME:TEXT OUTPUT lottu03.sql [root@sdserver40_222 ~]# ora2pg -c /etc/ora2pg/ora2pg.conf [========================>] 1/1 tables (100.0%) end of scanning. [========================>] 1/1 tables (100.0%) end of table export. [root@sdserver40_222 ~]# cat lottu03.sql -- Generated by Ora2Pg, the Oracle database Schema converter, version 17.4 -- Copyright 2000-2016 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:Oracle:ora229 SET client_encoding TO ‘UTF8‘; \set ON_ERROR_STOP ON CREATE TABLE lottu01 ( id int, name text ) ;
解释:
[root@sdserver40_222 ~]# ora2pg -c /etc/ora2pg/ora2pg.conf [========================>] 2/2 functions (100.0%) end of output. [root@sdserver40_222 ~]# cat lottu04.sql -- Generated by Ora2Pg, the Oracle database Schema converter, version 17.4 -- Copyright 2000-2016 Gilles DAROLD. All rights reserved. -- DATASOURCE: dbi:Oracle:ora229 SET client_encoding TO ‘UTF8‘; \set ON_ERROR_STOP ON CREATE OR REPLACE FUNCTION ora2pg_16_to10 (v_16_data text) RETURNS bigint AS $body$ DECLARE v_data bigint; v_char varchar(18); BEGIN v_char:=substring(v_16_data from 2); select sum(data) into v_data from ( SELECT ( case substr(upper(v_char),rownum,1) when ‘A‘ then ‘10‘ when ‘B‘ then ‘11‘ when ‘C‘ then ‘12‘ when ‘D‘ then ‘13‘ when ‘E‘ then ‘14‘ when ‘F‘ then ‘15‘ else substring(v_char from rownum for 1) end )*power(16,length(v_char)-rownum) data connect by rownum<=length(v_char) ); return v_data; exception when others then return null; end; $body$ LANGUAGE PLPGSQL SECURITY DEFINER ; -- REVOKE ALL ON FUNCTION ora2pg_16_to10 (v_16_data text) FROM PUBLIC; CREATE OR REPLACE FUNCTION ora2pg_add_1 (v_in_1 bigint,v_in_2 bigint) RETURNS bigint AS $body$ DECLARE v_data bigint; BEGIN v_data := v_in_1+v_in_2; return v_data; exception when others then return null; end; $body$ LANGUAGE PLPGSQL SECURITY DEFINER ; -- REVOKE ALL ON FUNCTION ora2pg_add_1 (v_in_1 bigint,v_in_2 bigint) FROM PUBLIC; [root@sdserver40_222 ~]# cat /etc/ora2pg/ora2pg.conf ORACLE_HOME /u01/app/oracle #This directive is used to set the data source name in the form standard DBI DSN ORACLE_DSN dbi:Oracle:ora229 ORACLE_USER lottu ORACLE_PWD li0924 LOGFILE /tmp/Ora2Pg.log SCHEMA LOTTU TYPE FUNCTION ALLOW ORA2PG_.* OUTPUT lottu04.sql
备注:
标签:sha this set convert case 函数导出 not sql cti
原文地址:http://www.cnblogs.com/lottu/p/5993981.html