Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
postgresql: create an integer with limited length
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
pactoo
Guru
Guru


Joined: 18 Jul 2004
Posts: 553

PostPosted: Mon Nov 28, 2005 2:55 pm    Post subject: postgresql: create an integer with limited length Reply with quote

Hello,

I have a problem with postgresql 7.4 in that the statement:
Code:

CREATE TABLE schema.table  ( "User" varchar(64) NOT NULL default '', "Uid" int(11) NOT NULL default '-1');

fails. Works, if the fieldlength for integer has not been specified:
Code:

CREATE TABLE schema.table  ( "User" varchar(64) NOT NULL default '', "Uid" int NOT NULL default '-1' );


Now, I am new to sql, but I have found a lot of different sql scripts in the internet specifically for postgresql that use a statement like int(11), which at least here produces a reproducable error.
Basically this is taken from a script for storing pureftpd users in a postgres database. So I wonder wether integer(n) is wrong sql or an misconfiguration an my side.
Back to top
View user's profile Send private message
jk3us
Apprentice
Apprentice


Joined: 14 Mar 2005
Posts: 201
Location: Memphis, TN

PostPosted: Mon Nov 28, 2005 6:00 pm    Post subject: Reply with quote

in postgres, an integer is a 32-bit value, and you can't change that. What do you mean when you want a length of 11? 11 decimal digits? If so, then you'll want the numeric type. so instead of int(11), try numeric(11). See http://www.postgresql.org/docs/8.1/interactive/datatype.html#DATATYPE-NUMERIC-DECIMAL
Back to top
View user's profile Send private message
pactoo
Guru
Guru


Joined: 18 Jul 2004
Posts: 553

PostPosted: Tue Nov 29, 2005 10:08 am    Post subject: Reply with quote

So the types are database dependend and not standarized by sql (yeah, I know, it QUERY language). Thanks very much for your input.
So I'd probably just had bad luck with my search for postgres scripts.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum