Re: MySQL to Postgres question

From: Paul Boddie <paul(at)boddie(dot)org(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: MySQL to Postgres question
Date: 2008-03-21 16:46:42
Message-ID: 80a140b8-6b7f-4f64-be32-0596771a5287@s13g2000prd.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21 Mar, 17:15, comedian(dot)watch(dot)(dot)(dot)(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2008-03-21 16:47:19 Re: MySQL to Postgres question
Previous Message Andreas Kretschmer 2008-03-21 16:42:18 Re: Table size