dbTalk Databases Forums  

Integer with size/length, e.g. INTEGER(11)?

comp.databases.postgresql comp.databases.postgresql


Discuss Integer with size/length, e.g. INTEGER(11)? in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karsten Wutzke
 
Posts: n/a

Default Integer with size/length, e.g. INTEGER(11)? - 09-05-2009 , 12:36 PM






Hi, I'm not using PostgreSQL yet. I just wanted to know if INTEGER(n),
like INTEGER(11) or such are allowed by PostgreSQL.

Does the value in parentheses cause an error or is it forwarded to
DECIMAL(p) (or NUMERIC(p)), like DECIMAL(11) or DECIMAL(11, 0)?

Karsten

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Integer with size/length, e.g. INTEGER(11)? - 09-05-2009 , 12:55 PM






Karsten Wutzke wrote on 05.09.2009 19:36:
Quote:
Hi, I'm not using PostgreSQL yet. I just wanted to know if INTEGER(n),
like INTEGER(11) or such are allowed by PostgreSQL.
No, it's not allowed. What should this mean anyway?

The datatype INTEGER already implies a specific range, so it does not make any sense at all to change this range by supplying an additional argument.

If you want a different range for a "whole number" you need to choose a different data type.

More details are here:
http://www.postgresql.org/docs/curre...l#DATATYPE-INT

Quote:
Does the value in parentheses cause an error
Yes.
Postgres does not try to guess what you might have meant when an error in the SQL is detected.

Thomas

Reply With Quote
  #3  
Old   
Karsten Wutzke
 
Posts: n/a

Default Re: Integer with size/length, e.g. INTEGER(11)? - 09-05-2009 , 01:09 PM



On 5 Sep., 19:55, Thomas Kellerer <OTPXDAJCS... (AT) spammotel (DOT) com> wrote:
Quote:
Karsten Wutzke wrote on 05.09.2009 19:36:

Hi, I'm not using PostgreSQL yet. I just wanted to know if INTEGER(n),
like INTEGER(11) or such are allowed by PostgreSQL.

No, it's not allowed. What should this mean anyway?

The datatype INTEGER already implies a specific range, so it does not make any sense at all to change this range by supplying an additional argument.

If you want a different range for a "whole number" you need to choose a different data type.

More details are here:http://www.postgresql.org/docs/curre...numeric.html#D...

Does the value in parentheses cause an error

Yes.
Postgres does not try to guess what you might have meant when an error in the SQL is detected.

Thomas
Great answer. Thanks! I was asking because MySQL allows INTEGER(n). If
you're interested to know, even if it doesn't make sense, it's only a
spacefill, visual length, e.g. for the command line client or as
queryable meta data. Whatever. ;-)

Karsten

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.