Unix Technical Forum

Re: converting Oracle scripts to PostgreSQL

This is a discussion on Re: converting Oracle scripts to PostgreSQL within the pgsql Sql forums, part of the PostgreSQL category; --> Gary Broadbent wrote: >Hi, > >I have a database in Oracle that I want to convert to PostgreSQL. > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:53 AM
Dennis Sacks
 
Posts: n/a
Default Re: converting Oracle scripts to PostgreSQL

Gary Broadbent wrote:

>Hi,
>
>I have a database in Oracle that I want to convert to PostgreSQL.
>
>I have exported the scripts used to create the tables, constraints and
>sequences in Oracle and wish to convert these to postgreSQL scripts now.
>
>Is there an easy way to do this?
>
>


These aren't too hard (stored procedures are what can be a bit more
tricky). Here are some hints I've gotten in my notes. I'm sure there is
more:

data types -

number can be changed to decimal
date should be changed to timestamp (oracle's date has time,
postgresql's doesn't)
varchar2 needs to be changed to varchar

There may be optimizer hints for oracle that are part of the table
definitions - you'll need to remove those.

Sequences are pretty close. I think I had to get rid of "NOORDER" and
change "NOCYCLE" to "NO CYCLE" and add "MINVALUE 0" since the Oracle
sequence specified "START WITH 0" in this example:

Oracle:

CREATE SEQUENCE ABC_DEP_SEQ INCREMENT BY 1 START WITH 0 NOCYCLE CACHE 20
NOORDER;

Postgresql:

CREATE SEQUENCE ABC_DEP_SEQ INCREMENT BY 1 START WITH 0 MINVALUE 0 NO
CYCLE CACHE 20 ;

Queries:

Queries may need to be rewritten if they use the Oracle syntax for outer
joins. Also the NVL function can be replaced with coalesce and DECODE
will need to be rewritten with CASE.

SYSDATE can be replaced with NOW()

Also check out this doc for more hints:

http://www-2.cs.cmu.edu/~pmerson/doc...ToPostgres.pdf

Dennis Sacks
dennis@illusions.com




---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com