Re: MySQL to Postgres question

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: "Edward Blake" <comedian(dot)watchman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: MySQL to Postgres question
Date: 2008-03-21 16:26:10
Message-ID: 20080321092610.3874b4f7@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 21 Mar 2008 12:15:05 -0400
"Edward Blake" <comedian(dot)watchman(at)gmail(dot)com> 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),
> 10 KEY subclass_id (subclass_id),
> 11 KEY department_id (department_id)
> 12 );
>
> Any ideas?

http://www.postgresql.org/docs/8.3/static/sql-createtable.html

I have no idea what KEY means in MySQL. Is it supposed to create an
INDEX? If so, you will need to create the indexes (not including the
PRIMARY KEY) after you create the table.

And just a quick editor view, you spelled description incorrectly in
product_descrition and your product_id is your primary key so you don't
have to set it NOT NULL.

Joshua D. Drake

- --
The PostgreSQL Company since 1997: http://www.commandprompt.com/
PostgreSQL Community Conference: http://www.postgresqlconference.org/
United States PostgreSQL Association: http://www.postgresql.us/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH4+GiATb/zqfZUUQRAqnnAJ424OFzGg23QFyKEy+MuiAVii02MQCfZL6Z
grPtt4bz9bwTcQYBgiuPTQM=
=U4S5
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2008-03-21 16:26:39 Re: Table size
Previous Message Edward Blake 2008-03-21 16:15:05 MySQL to Postgres question