Created
June 18, 2013 14:56
-
-
Save ppdeassis/5806050 to your computer and use it in GitHub Desktop.
Using Ora2PG migration tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # homepage: http://ora2pg.darold.net | |
| # pre-requisites | |
| # perl 5.6+ | |
| perl -v | |
| # DBI perl module (-i install, -f force) | |
| cpan -i -f DBI | |
| # DBD::Oracle module | |
| cpan -i -f DBD::Oracle | |
| # installation | |
| # download at: http://sourceforge.net/projects/ora2pg/ | |
| tar xjf ora2pg-8.7.tar.bz2 | |
| cd ora2pg-8.7/ | |
| perl Makefile.PL | |
| make && make install | |
| # ora2pg.conf SAMPLE (SCHEMA, TABLE, etc must be in uppercase) | |
| # sid is the database name (check databases at /etc/oratab file) | |
| ORACLE_DSN dbi:Oracle:host=localhost;sid=orcl | |
| ORACLE_USER my_user | |
| ORACLE_PWD passwd | |
| # will default to postgres default schema ("public") | |
| EXPORT_SCHEMA 0 | |
| # schema is a username (owner) | |
| SCHEMA SCHEMA_USERNAME_MUST_BE_UPPERCASE | |
| # to export table, but the script suggested below changes it for each type in a for loop | |
| TYPE TABLE | |
| NLS_LANG "BRAZILIAN PORTUGUESE_BRAZIL.UTF8 | |
| CLIENT_ENCODING UTF-8 | |
| # simple export shell script | |
| for i in TABLE PACKAGE COPY VIEW GRANT SEQUENCE TRIGGER FUNCTION PROCEDURE TABLESPACE ;\ | |
| do \ | |
| perl -p -i -e "s/^TYPE\s+.*/TYPE $i/; s/^OUTPUT\s+.*/OUTPUT $i.sql/" ora2pg.conf; \ | |
| ora2pg --conf ora2pg.conf; \ | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment