Unix Technical Forum

Re: Query in SQL statement

This is a discussion on Re: Query in SQL statement within the pgsql Hackers forums, part of the PostgreSQL category; --> I think this question may be more appropriate for pgsql-novice@postgresql.org . Anyrate for the below. Sounds like you maybe ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 06:00 AM
Obe, Regina DND\\MIS
 
Posts: n/a
Default Re: Query in SQL statement

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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:44 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com