X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E2525D8F14; Thu, 29 Sep 2005 10:28:38 -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 11070-03; Thu, 29 Sep 2005 13:28:35 +0000 (GMT) Received: from vscan03.westnet.com.au (vscan03.westnet.com.au [203.10.1.142]) by svr1.postgresql.org (Postfix) with ESMTP id 10F82D706A; Thu, 29 Sep 2005 10:28:35 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 4CABAB601AD; Thu, 29 Sep 2005 21:28:38 +0800 (WST) Received: from vscan03.westnet.com.au ([127.0.0.1]) by localhost (vscan03.westnet.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29906-09; Thu, 29 Sep 2005 21:28:38 +0800 (WST) Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan03.westnet.com.au (Postfix) with ESMTP id B9089B6006B; Thu, 29 Sep 2005 21:28:37 +0800 (WST) Message-ID: <433BEC06.40004@familyhealth.com.au> Date: Thu, 29 Sep 2005 21:28:38 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) 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.112 required=5 tests=[AWL=-0.095, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200509/1361 X-Sequence-Number: 73758 > CREATE SEQUENCE ai_id; > 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, > Reason varchar(200), > Admin varchar(30) DEFAULT '-', > PRIMARY KEY (id), > KEY UserName (UserName), > KEY Date (Date) > ); > > > Am always getting foll. Errors, > > ERROR: relation "ai_id" already exists > ERROR: syntax error at or near "(" at character 240 You have just copied the Mysql code to Postgresql. It will in no way work. Your default for 'Date' is illegal in postgresql and hence it must allow NULLs. There is no such thing as a 'datetime' type. There is no such thing as 'Key'. Also your mixed case identifiers won't be preserved. You want: CREATE TABLE badusers ( id SERIAL PRIMARY KEY, UserName varchar(30), Date timestamp, Reason varchar(200), Admin varchar(30) DEFAULT '-' ); CREATE INDEX UserName_Idx ON badusers(Username); CREATE INDEX Date_Idx ON badusers(Date);