Обсуждение: creating tables using a file

Поиск
Список
Период
Сортировка

creating tables using a file

От
Kusuma Pabba
Дата:
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?

if yes how?
Do i need to make any changes to the file?
Thanks for any help


Regards
 kusuma.p

Re: creating tables using a file

От
Craig Ringer
Дата:
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

Re: creating tables using a file

От
"A. Kretschmer"
Дата:
In response to Kusuma Pabba :
> 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?

Sure, psql -f or within psql with \i.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net