Search Postgresql Archives

Re: auto-increment field : in a simple way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Oct 11, 2012 at 5:11 PM, Vineet Deodhar <vineet.deodhar@xxxxxxxxx> wrote:
On Thu, Oct 11, 2012 at 12:56 PM, Scott Marlowe <scott.marlowe@xxxxxxxxx> wrote:

Can't you just add this to your create table:


CREATE TABLE tablename (
   colname SERIAL
, check (colname>0 and colname < 32768));
);



With this constraint, whether the storage space requirement would reduce?
OR
Is it just for validation of data?

--- Vineet

Well, there's smallserial when creating tables...

create table test(a smallserial);
NOTICE:  CREATE TABLE will create implicit sequence "test_a_seq" for serial column "test.a"
CREATE TABLE

                         Table "public.test"
 Column |   Type   |                    Modifiers                     
--------+----------+--------------------------------------------------
 a      | smallint | not null default nextval('test_a_seq'::regclass)

--
JC de Villa

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux