0
点赞
收藏
分享

微信扫一扫

sql returning

在​​INSERT​​ INTO或者UPDATE的时候在最后面加上RETURNING colname,PostgreSQL会在插入或者更新数据之后会返回你指定的字段

postgres=# insert into tb3(name) values('aa')returning name;
name
------
aa
(1 row)

INSERT 0 1
postgres=# insert into tb3(name) values('aa')returning id;
id
----
2
(1 row)

INSERT 0 1
postgres=# insert into tb3(name) values('aa')returning id,name;
id | name
----+------
3 | aa
(1 row)

INSERT 0 1

 

举报

相关推荐

0 条评论