如何限制postgresql中特定列的插入值?

时间:2017-04-11 15:22:04

标签: sql postgresql

我将有一个id列,我使用的是串行类型,因此它会独立生成一个数字。我想限制为该列插入自定义值。

1 个答案:

答案 0 :(得分:0)

使用t表:

create table t (
    c1 serial,
    c2 text
);

撤消公众和所有其他角色对序列列的权限:

revoke insert (c1), update (c1) on t from public, other_role;

将序列列的权限授予the_role

grant insert (c1), update (c1) on t to the_role;
相关问题