postgresql - Add a serial column based on a sorted column -
I have a table that has a column with an undeveloped value. I want to block this column and add a column to record its order. My SQL code is:
selectable * newtable from column_name desc by old locks order; Column ID serial to add table newtables;
Will this apply to my goal? I know that there are no fixed orders in the PostgreSQL rows. So I'm not sure about it.
Optional table (s) via SERIAL
, create it on insert-time
Create a new tablet table (ID serial exclusively tap, like all OLYNtableable); Select a new tablet in the next ('newtable_id_seq'), * oldtable ORDER BY column_name desc;
This avoids a table rewriting, and unlike your prior approach, the right order is guaranteed.
(If you want to be a PK, and there was no PK in the previous table, replace not unique empty
to primary key
if the first table If you had a PK, you would need to use the like
do not include the constraints
.
Comments
Post a Comment