I have a database in Postgresql, which was migrated from SQL Server (only data).
On SQL Server, a table from this database has these columns:
measure_id
datum
measure
where measure_id
is auto-incremental primary key, datum
is datetime and measure
is float.
After migration in Postrgresql, measure_id
is column of type bigint.
How can I change this column (measure_id
) to bigserial and assign it as primary key, now that my table is full of data?
Best Answer
Create a sequence and use it as the default value for the column:
That essentially what
serial
does.See the manual for details:
http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL