imos=# CREATETABLE person (
imos(# id SERIAL,
imos(# name TEXT
imos(# );
CREATETABLE
imos=#
imos=#
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') RETURNING id;
id
----1
(1row)
INSERT01
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') RETURNING id;
id
----2
(1row)
INSERT01
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') RETURNING *;
id | name
----+---------------3| Blaise Pascal
(1row)
INSERT01
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') RETURNING null;
?column?
----------
(1row)
INSERT01
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') ;
INSERT01
delete 操作并返回结果
imos=# select*from person;
id | name
----+---------------1| Blaise Pascal
2| Blaise Pascal
3| Blaise Pascal
4| Blaise Pascal
5| Blaise Pascal
(5rows)
imos=# deletefrom person where id=1;
DELETE1
imos=# select*from person;
id | name
----+---------------2| Blaise Pascal
3| Blaise Pascal
4| Blaise Pascal
5| Blaise Pascal
(4rows)
imos=# deletefrom person where id=2 returning *;
id | name
----+---------------2| Blaise Pascal
(1row)
DELETE1
imos=# deletefrom person where id=3 returning null;
?column?
----------
(1row)
DELETE1
imos=# select*from person;
id | name
----+---------------4| Blaise Pascal
5| Blaise Pascal
(2rows)
imos=# deletefrom person where id=4 returning name;
name
---------------
Blaise Pascal
(1row)
DELETE1
imos=# deletefrom person where id=5 returning id;
id
----5
(1row)
DELETE1
imos=# select*from person;
id | name
----+------
(0rows)
update操作并返回结果
imos=# select*from person;
id | name
----+------
(0rows)
imos=#
imos=#
imos=#
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal') ;
INSERT01
imos=# select*from person;
id | name
----+---------------6| Blaise Pascal
(1row)
imos=# INSERTINTO person (name) VALUES ('Blaise Pascal32') ;
INSERT01
imos=# select*from person;
id | name
----+-----------------6| Blaise Pascal
7| Blaise Pascal32
(2rows)
imos=# update person set name='test'where id=6 returning *;
id | name
----+------6| test
(1row)
UPDATE1
imos=# select*from person;
id | name
----+-----------------7| Blaise Pascal32
6| test
(2rows)
imos=# update person set name='test'where id=7 returning name;
name
------
test
(1row)
UPDATE1
imos=# select*from person;
id | name
----+------6| test
7| test
(2rows)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 《HelloGitHub》第 106 期
· 数据库服务器 SQL Server 版本升级公告
· 深入理解Mybatis分库分表执行原理
· 使用 Dify + LLM 构建精确任务处理应用