2017-04-11 87 views
0

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

+1

行安全策略在这里没有帮助我想 - 你可以创建一个触发器,临时表t忽略NEW.id将其替换为nexvat(seq) –

回答

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;