X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3F50DA17A; Wed, 5 Oct 2005 05:57:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94444-08; Wed, 5 Oct 2005 08:57:02 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 62192DA166; Wed, 5 Oct 2005 05:57:03 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id D8BF8414283; Wed, 5 Oct 2005 09:55:24 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 5452C15EDA; Wed, 5 Oct 2005 09:54:16 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12230-04; Wed, 5 Oct 2005 09:54:12 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E768615ED5; Wed, 5 Oct 2005 09:54:11 +0100 (BST) Message-ID: <434394B3.4070009@archonet.com> Date: Wed, 05 Oct 2005 09:54:11 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "R, Rajesh (STSD)" Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Query in SQL statement References: <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> In-Reply-To: <5CBFB210D9870F40B9E5A0FBD31F3A770283AC48@bgeexc01.asiapacific.cpqcorp.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/91 X-Sequence-Number: 14859 R, Rajesh (STSD) wrote: > > Am trying to port a mysql statement to postgres. > > Please help me in finding the error in this, Can I recommend the reference section of the manuals for this sort of thing? There is an excellent section detailing the valid SQL for the CREATE TABLE command. Also - the pgsql-hackers list is for discussion of database development, and the performance list is for performance problems. This would be better posted on pgsql-general or -sql or -novice. > CREATE SEQUENCE ai_id; This line is causing the first error: > ERROR: relation "ai_id" already exists That's because you've already successfully created the sequence, so it already exists. Either drop it and recreate it, or stop trying to recreate it. > CREATE TABLE badusers ( > id int DEFAULT nextval('ai_id') NOT NULL, > UserName varchar(30), > Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, Well, "Date" is a type-name, "datetime" isn't and even if it was "0000-00-00" isn't a valid date is it? > Reason varchar(200), > Admin varchar(30) DEFAULT '-', > PRIMARY KEY (id), > KEY UserName (UserName), > KEY Date (Date) The word "KEY" isn't valid here either - are you trying to define an index? If so, see the "CREATE INDEX" section of the SQL reference. http://www.postgresql.org/docs/8.0/static/sql-commands.html If you reply to this message, please remove the pgsql-hackers CC: -- Richard Huxton Archonet Ltd