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

From Paul Boddie
Subject Re: MySQL to Postgres question
Date
Msg-id 80a140b8-6b7f-4f64-be32-0596771a5287@s13g2000prd.googlegroups.com
Whole thread Raw
In response to MySQL to Postgres question  ("Edward Blake" <comedian.watchman@gmail.com>)
List pgsql-general
On 21 Mar, 17:15, comedian.watch...@gmail.com ("Edward Blake") wrote:
>
> When I try and rewrite it as a Postgres statement (below), it fails at line
> 9.
>  0 SET CONSTRAINTS ALL DEFERRED;
>  1 CREATE TABLE products (
>  2      product_id serial[11] not null,
>  3      product_name varchar[255] not null,
>  4      product_descrition varchar[255] not null,
>  5      class_id integer[11] not null,
>  6      subclass_id integer[11] not null,
>  7      department_id integer[11] not null
>  8      PRIMARY KEY (product_id),
>  9      KEY class_id (class_id),

Isn't KEY a MySQL shorthand for creating an index within the table
declaration. Why not create the index afterwards using CREATE INDEX
instead?

> 10      KEY subclass_id (subclass_id),
> 11      KEY department_id (department_id)
> 12 );
>
> Any ideas?

Yes, just decouple the index declarations from the table declaration.
There are benefits to doing this, too, such as being able to populate
tables more rapidly before the indexes are added - a technique which
appears to be useful for certain kinds of applications.

Paul

pgsql-general by date:

Previous
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: [postgis-users] how many min. floating-points?
Next
From: "Edward Blake"
Date:
Subject: MySQL to Postgres question