I saw on a previous thread that someone was saying you shouldn't rely on SERIAL. Could someone please explain exactly why this is? Thanks in advance.

    There's nothing wrong with the SERIAL type.

    You can create the sequence yourself or you can use the serial type, it's just a matter of taste.

      I think what they really meant was you should probably know what the serial pseudo type is doing so that if you need something different you can do it.

      For 99% of all autoincrementing primary keys, serial is a fine way to define it in postgresql. But remember that this is not the standard SQL way of doing things, and if you are writing code that creates sequences and such for admin purposes, you should probably stick to creating the sequences by hand so your code will be more portable to other SQL 92 compliant DBMSes.

      If you're a bit of a newbie, the serial type is a real god send, since it makes it so easy to make an autoincementing primary key that just plain works and works well.

        Write a Reply...