Re: creating tables using a file - Mailing list pgsql-general

From Craig Ringer
Subject Re: creating tables using a file
Date
Msg-id 499275A6.2090800@postnewspapers.com.au
Whole thread Raw
In response to creating tables using a file  (Kusuma Pabba <kusumap@ncoretech.com>)
List pgsql-general
Kusuma Pabba wrote:
> hello all,
>    i have used a file containing all the queries and directly executed
> the file  to create tables in mysql, now i want to use the same for psql
> is it
> possible?

psql -f filename.sql

> Do i need to make any changes to the file?

Lots. PostgreSQL and MySQL have quite significantly different SQL
dialects, and even where they support the same syntax the semantic
meaning may not be exactly the same.

You will need to correct for things like use of MySQL "AUTO_INCREMENT"
fields. PostgreSQL doesn't have that at all, it uses transaction-safe
sequences (and the SERIAL helper pseudo-type) instead. The behaviour is
different, and there is no exact equivalent for AUTO_INCREMENT. For good
reasons, as there are lots of problems with AUTO_INCREMENT, but it does
complicate porting schema.

There are lots of other differences, too. Tools do exist to convert
MySQL schema to PostgreSQL syntax and adjust for common differences, but
I'm not sure how effective they really are.

--
Craig Ringer

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: 'text' is gone?
Next
From: John R Pierce
Date:
Subject: Re: Intel SSD