Add a column to existing table and uniquely number them on MS SQL Server

前端 未结 8 1270
暖寄归人
暖寄归人 2020-12-04 08:16

I want to add a column to an existing legacy database and write a procedure by which I can assign each record a different value. Something like ad

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 08:43

    And the Postgres equivalent (second line is mandatory only if you want "id" to be a key):

    ALTER TABLE tableName ADD id SERIAL;
    ALTER TABLE tableName ADD PRIMARY KEY (id);
    

提交回复
热议问题