Skip site navigation (1) Skip section navigation (2)

Re: Query in SQL statement

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "R, Rajesh (STSD)" <rajesh(dot)r2(at)hp(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: Query in SQL statement
Date: 2005-09-29 13:28:38
Message-ID: 433BEC06.40004@familyhealth.com.au (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-performance
> 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);


In response to

Responses

pgsql-performance by date

Next:From: Gaetano MendolaDate: 2005-09-29 13:29:30
Subject: Re: Delete query takes exorbitant amount of time
Previous:From: Zeugswetter Andreas DAZ SDDate: 2005-09-29 13:28:27
Subject: Re: [PERFORM] A Better External Sort?

pgsql-hackers by date

Next:From: Obe, Regina DND\MISDate: 2005-09-29 13:30:17
Subject: Re: Query in SQL statement
Previous:From: Zeugswetter Andreas DAZ SDDate: 2005-09-29 13:28:27
Subject: Re: [PERFORM] A Better External Sort?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group