Sha*_*ddi 3 database postgresql jdbc limit
我可以运行带有 return 子句的更新查询并限制返回的行吗?例如,我运行一个 udate 查询,它更新了一百万条记录,但我不想将更新后的一百万行返回到结果集..只是一个示例,表示 1000 条记录。这可能吗?
我的查询:
UPDATE table1 SET col1 = value1 RETURNING *
Run Code Online (Sandbox Code Playgroud)
我想要更新的列数和更新后的 1000 行样本。
小智 5
with updated as (
update the_table_with_many_rows
set some_column = 42
where ...
returning *
)
select u.*,
count(*) over () as total_update_count
from updated as u
limit 1000;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3615 次 |
最近记录: |