Re: MySQL to Postgres question - Mailing list pgsql-general

From Tom Lane
Subject Re: MySQL to Postgres question
Date
Msg-id 24780.1206117269@sss.pgh.pa.us
Whole thread Raw
In response to MySQL to Postgres question  ("Edward Blake" <comedian.watchman@gmail.com>)
List pgsql-general
"Edward Blake" <comedian.watchman@gmail.com> writes:
> When I try and rewrite it as a Postgres statement (below), it fails at line
> 9.
>  0 SET CONSTRAINTS ALL DEFERRED;

I don't think that does the same thing as mysql's foreign_key_checks = 0.

>  2      product_id serial[11] not null,

This is trying to create an array, it is not at all the same as integer(11).
All of your other uses of square brackets are wrong too.  The varchars
will be okay with (255) but you should just drop the (11)'s --- use
either plain integer or bigint depending on what range you need.

>  9      KEY class_id (class_id),

PG doesn't have this type of clause within CREATE TABLE.  To create
a non-unique index you need a separate CREATE INDEX statement, eg

CREATE INDEX products_class_id ON products(class_id);

            regards, tom lane

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: deadlock error messages
Next
From: Andreas Kretschmer
Date:
Subject: Re: Table size