相关疑难解决方法(0)

序列作为列的默认值

我已经创建了一个序列:

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)

t-sql sql-server sequence sql-server-2012

22
推荐指数
2
解决办法
3万
查看次数

标签 统计

sequence ×1

sql-server ×1

sql-server-2012 ×1

t-sql ×1