Re: [HACKERS] Query in SQL statement - Mailing list pgsql-performance

From Obe, Regina DND\\MIS
Subject Re: [HACKERS] Query in SQL statement
Date
Msg-id 35F9812087218F47B050D41D1B58298B086F3D@dnd5.dnd.boston.cob
Whole thread Raw
List pgsql-performance
I think this question may be more appropriate for
pgsql-novice@postgresql.org.

Anyrate for the below.  Sounds like you maybe already have a table or
sequence called ai_id;

Try doing a DROP SEQUENCE ai_id;

First

Also if you plan to use this sequence only for this table it would be better
to use serial8 which will automatically create the sequence for you. Then
you don't even need that first part.  Also you should avoid naming fields
things like Date which tend to be keywords in many kinds of databases.

Try changing your logic to something like

CREATE TABLE badusers (
  id serial8,
  UserName varchar(30),
  Date  timestamp DEFAULT now() NOT NULL,
  Reason varchar(200),
  Admin varchar(30) DEFAULT '-',
  PRIMARY KEY (id)
);

CREATE INDEX badusers_username
  ON badusers
  USING btree
  (username);

CREATE INDEX badusers_date
  ON badusers
  USING btree
  (date);

-----Original Message-----
From: R, Rajesh (STSD) [mailto:rajesh.r2@hp.com]
Sent: Thursday, September 29, 2005 9:05 AM
To: pgsql-hackers@postgresql.org; pgsql-performance@postgresql.org
Subject: [HACKERS] Query in SQL statement



Am trying to port a mysql statement to postgres.

Please help me in finding the error in this,


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

Thanks,
Rajesh R

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly

pgsql-performance by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [HACKERS] A Better External Sort?
Next
From: David Fetter
Date:
Subject: Re: [HACKERS] A Better External Sort?