Re: auto-increment field : in a simple way

From: JC de Villa <jc(dot)devilla(at)gmail(dot)com>
To: Vineet Deodhar <vineet(dot)deodhar(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: auto-increment field : in a simple way
Date: 2012-10-11 09:25:04
Message-ID: CAOvw+Nb89kY0saNH8EUv6ZEay6e7Q0bg7_OdKz7WYqqaVeiK7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 11, 2012 at 5:11 PM, Vineet Deodhar <vineet(dot)deodhar(at)gmail(dot)com>wrote:

> On Thu, Oct 11, 2012 at 12:56 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2012-10-11 09:34:15 Re: Storing large files in multiple schemas: BLOB or BYTEA
Previous Message Condor 2012-10-11 09:23:40 How to raise index points when equal and like is used with gist ?