[GENERAL] Resetting serial type after "delete from table"

2010-05-08 Thread John Gage
If I "delete from table", which table contains a serial type field,  
and then insert new rows into the table "excluding the [serial] column  
from the list of columns in the INSERT statement", the numbers in the  
serial column resume where they left  off prior to the "delete from   
table": 639, 640, 641, 642 for example.


This behavior is totally acceptable, but is it possible to have the  
serial column reset itself to 1 following  "delete from table" (i.e.  
following flushing all the rows from the table)?  The only way I can  
think to do this is by altering the table by dropping the serial  
column and then altering it again by adding a new serial column before  
doing the insert.  That is only a couple of more lines of script, so I  
don't do the work, but is there an easier way?


Thanks,

John

Re: [GENERAL] Resetting serial type after "delete from table"

2010-05-08 Thread Leif Biberg Kristensen
On Saturday 8. May 2010 10.11.32 John Gage wrote:
> If I "delete from table", which table contains a serial type field,  
> and then insert new rows into the table "excluding the [serial] column  
> from the list of columns in the INSERT statement", the numbers in the  
> serial column resume where they left  off prior to the "delete from   
> table": 639, 640, 641, 642 for example.
> 
> This behavior is totally acceptable, but is it possible to have the  
> serial column reset itself to 1 following  "delete from table" (i.e.  
> following flushing all the rows from the table)?  The only way I can  
> think to do this is by altering the table by dropping the serial  
> column and then altering it again by adding a new serial column before  
> doing the insert.  That is only a couple of more lines of script, so I  
> don't do the work, but is there an easier way?

http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-
SERIAL

http://www.postgresql.org/docs/current/static/functions-sequence.html

regards,
-- 
Leif Biberg Kristensen
http://solumslekt.org/blog/

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Resetting serial type after "delete from table"

2010-05-08 Thread John Gage

Thanks very, very much.  I got as far as 8.1.4 and did not find 9.15.

May I suggest that the documentation have an index entry under  
"serial" for 9.15, which is a major heading whereas 8.1.4 is a minor  
heading and has its own index entry?


This is said from the perspective of awe for the documentation.

John


On May 8, 2010, at 10:30 AM, Leif Biberg Kristensen wrote:

http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-
SERIAL

http://www.postgresql.org/docs/current/static/functions-sequence.html




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general