X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A40403A57D8 for ; Tue, 25 Jan 2005 18:26:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01028-07 for ; Tue, 25 Jan 2005 18:26:28 +0000 (GMT) Received: from illusions.com (unknown [69.28.129.146]) by svr1.postgresql.org (Postfix) with SMTP id 609163A5792 for ; Tue, 25 Jan 2005 18:26:26 +0000 (GMT) Received: (qmail 1705 invoked from network); 25 Jan 2005 18:26:53 -0000 Received: from localhost (HELO ?127.0.0.1?) (127.0.0.1) by illusions.com with SMTP; 25 Jan 2005 18:26:53 -0000 Message-ID: <41F68F93.6040009@illusions.com> Date: Tue, 25 Jan 2005 11:27:31 -0700 From: Dennis Sacks User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gary.Broadbent@gtnet.com Cc: pgsql-sql@postgresql.org Subject: Re: converting Oracle scripts to PostgreSQL References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.832 tagged_above=0 required=5 tests=RCVD_IN_BL_SPAMCOP_NET X-Spam-Level: * X-Archive-Number: 200501/226 X-Sequence-Number: 20014 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/docs/OracleToPostgres.pdf Dennis Sacks dennis@illusions.com