logobosspolice

Serial Postgres Alter

Serial Postgres Alter Rating: 8,6/10 8926 reviews
Active4 years, 10 months ago
  1. Postgres Alter Table Column
  2. Postgres Alter Type

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:

When upgrading a field / changing it's type using pgsql:changeField, it's impossible to make a field a serial, bigserial, or numeric. This appears to be because of confusion between the typecast that is required to do the data-conversion and the field-type we are creating. As is currently stands,. PostgreSQL SELECT primary key as “serial” or “bigserial”. Standard behaviour in executing multiple alter statements in Postgres. Hot Network Questions Ex-contractor published company source code and secrets online How to vertically align the three columns of my table top, top, middle How does The Fools Guild make its money?

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.

Serial

How can I change this column (measure_id) to bigserial and assign it as primary key, now that my table is full of data?

Aaron Bertrand
159k19 gold badges316 silver badges523 bronze badges
Postgres
zetahzetah

1 Answer

Nozzle pro download crack for gta. Create a sequence and use it as the default value for the column:

That essentially what serial does.

Postgres Alter Table Column

See the manual for details:
http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL

Postgres Alter Type

Postgresa_horse_with_no_namea_horse_with_no_name
45.7k9 gold badges89 silver badges122 bronze badges

Not the answer you're looking for? Browse other questions tagged postgresqlmigrationpostgresql-9.3 or ask your own question.