sql - Alter data type of a column to serial -
in pgsql, there way have table of several values, , choose 1 of them (say, other_id), find out highest value , make every new entry put in table increment value.
i suppose easy have had chance of working..
alter table address alter column new_id type serial ____________________________________ error: type "serial" not exist thanks insight!
a quick glance @ docs tells
the data types smallserial, serial , bigserial are not true types merely notational convenience creating unique identifier columns
if want make existing (integer) column work "serial", create sequence hand (the name arbitrary), set current value maximum (or bigger) of current address.new_id value, @ set default value address.new_id column.
to set value of sequence see here.
select setval('address_new_id_seq', 10000);
this example, use own sequence name (arbitrary, create it), , number greater maximum current value of column.
update: pointed out lucas' answer (which should acccepted one) should specify column sequence "belongs to" using create/alter sequence ... owned ...
Comments
Post a Comment