软件下载吧文章资讯

分类分类

postgresql 如何实现replace into功能的代码

2024-02-07 12:09作者:下载吧

PostgreSQL 9.5-

使用函数或with实现

create table test(id int primary key, info text, crt_time timestamp);
with upsert as (update test set info=’test’,crt_time=now() where id=1 returning *) insert into test select 1,’test’,now() where not exists (select 1 from upsert where id=1);

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消