Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I came across this post (What is the difference between tinyint, smallint, mediumint, bigint and int in sql?) and realized that PostgreSQL does not support unsigned integer.

Can anyone help to explain why is it so?

Most of the time, I use unsigned integer as auto incremented primary key in MySQL. In such design, how can I overcome this when I port my database from MySQL to PostgreSQL?

Thanks.

share|improve this question
 
you got over 2^31 records in them yet? –  Tony Hopkinson Dec 28 at 1:53
 
Not yet but soon and we are considering to move to PostgreSQL. –  Adrian Hoe Dec 28 at 1:55
1  
I don't think this is the best place to be asking why certain decisions were made, one of the PostgreSQL mailing lists might be more suitable. If you want auto-incrementing values then use serial (1 to 2147483647) or bigserial (1 to 9223372036854775807). A signed 64bit integer probably offers more than enough room. –  mu is too short Dec 28 at 1:55
 
Thanks @muistooshort. That answered the primary key issue. But how about an unsigned integer type which is not auto incremented nor primary key? I do have columns which store unsigned integer which has a range from 0 to 2^32. –  Adrian Hoe Dec 28 at 1:59
 
A quick run through the PostgreSQL docs (postgresql.org/docs/current/interactive/index.html) might be useful to help you get a better idea of what PostgreSQL is capable of. The only reason I'd use MySQL these days is if I already had a lot invested in it: PostgreSQL is fast, loaded with useful features, and built by people that are pretty paranoid about their data. IMO of course :) –  mu is too short Dec 28 at 2:04
show 1 more comment

1 Answer

It's not in the SQL standard, so the general urge to implement it is lower.

Having too many different integer types makes the type resolution system more fragile, so there is some resistance to adding more types into the mix.

That said, there is no reason why it couldn't be done. It's just a lot of work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.