Re: [SQL] customising serial type

2005-06-21 Thread Krasimir Dimitrov
On Tuesday 21 June 2005 13:01, you wrote:
> hi,
> in a table with a serial datatype, how do i get the sequence to start 
> at a specific number like 10?

ALTER SEQUENCE sequence_name RESTART WITH 10;

-- 

Krasimir Dimitrov
IT Department
AII Data Processing Ltd.,
16 Ivan Vazov Str,
Sofia 1000,
Bulgaria
Phone: +359 2 9376 352
E-mail: [EMAIL PROTECTED]
http://www.see-news.com

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[SQL] customising serial type

2005-06-21 Thread Kenneth Gonsalves
hi,
in a table with a serial datatype, how do i get the sequence to start 
at a specific number like 10?
-- 
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [SQL] customising serial type

2005-06-21 Thread Michael Glaesemann


On Jun 21, 2005, at 7:01 PM, Kenneth Gonsalves wrote:


in a table with a serial datatype, how do i get the sequence to start
at a specific number like 10?


The SERIAL datatype (e.g., CREATE TABLE foo(foo_id SERIAL) )is a  
shorthand for something like

CREATE SEQUENCE foo_id_seq;
CREATE TABLE foo (foo_id integer default nextval('foo_id_seq') );

If you want it to specify the start value, you'll need to either use  
CREATE SEQUENCE first and then create the table with the appropriate  
default, or use ALTER SEQUENCE after creating the table.


http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html
http://www.postgresql.org/docs/8.0/interactive/sql-altersequence.html

Michael Glaesemann
grzm myrealbox com

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match