将行号添加到新列

Pri*_*den 1 sql sybase rownum

我想创建一个新列并用行号填充该列中每行的值。

在oracle中可以通过这样做来实现。

alter table mytable add (myfield integer);
update mytable set myfield = rownum;
Run Code Online (Sandbox Code Playgroud)

在 SYBASE ASE 中如何完成此操作?

小智 6

alter table mytable 
add id bigint identity not null
Run Code Online (Sandbox Code Playgroud)

就这样。每行中都会有一列id包含该行的唯一序列号。