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

 

posted on 2022-07-12 15:08  我和你并没有不同  阅读(410)  评论(0编辑  收藏  举报