我需要将表的主键更改为标识列,并且表中已有许多行.
我有一个脚本来清理ID以确保它们从1开始顺序启动,在我的测试数据库上运行正常.
什么是将命令改为具有标识属性的SQL命令?
我已经创建了一个序列:
create sequence mainseq as bigint start with 1 increment by 1
Run Code Online (Sandbox Code Playgroud)
如何将此序列用作列的默认值?
create table mytable(
id bigint not null default mainseq -- how?
code varchar(20) not null
)
Run Code Online (Sandbox Code Playgroud)