小编Chl*_*loe的帖子

这个语句是如何在 Postgres 中更新 3 行的?

我很好奇这个语句是如何在 Postgres 中更新 3 行的。在我运行它的所有其他时间,它会更新 0 或 1。有没有办法找出哪些行?

bestsales=# update keyword set revenue = random()*10 where id = cast(random()*99999 as int);
UPDATE 3
Run Code Online (Sandbox Code Playgroud)

id 是主键。

 id               | integer                        | not null default nextval('keyword_id_seq'::regclass)
    "keyword_pkey" PRIMARY KEY, btree (id)
Run Code Online (Sandbox Code Playgroud)

我尝试将其运行为SELECT

bestsales=# select * from keyword where id = cast(random()*99999 as int);
  id   |       keyword       | seed_id | source | search_count | country | language | volume | cpc  | competition | modified_on | google_violation | revenue | bing_violation
-------+---------------------+---------+--------+--------------+---------+----------+--------+------+-------------+-------------+------------------+---------+---------------- …
Run Code Online (Sandbox Code Playgroud)

postgresql random update

4
推荐指数
2
解决办法
247
查看次数

这个唯一索引如何允许重复行?

有没有办法让这个唯一索引允许重复的行?我想也许有一些额外的空格字符,但我找不到它们。

=> select *, length(keyword), length(country), length(language) from keyword where id in (4588076, 4951423);
   id    |       keyword       | seed_id | source | search_count | country | language | volume | cpc  | competition | modified_on | violation | revenue | length | length | length
---------+---------------------+---------+--------+--------------+---------+----------+--------+------+-------------+-------------+-----------+---------+--------+--------+--------
 4588076 | power wallet review |         | SPYFU  |            0 |         |          |     70 | 0.11 |        0.31 |             |           |         |     19 |        |
 4951423 | power wallet review |         | SPYFU  | …
Run Code Online (Sandbox Code Playgroud)

postgresql index

1
推荐指数
1
解决办法
2979
查看次数

标签 统计

postgresql ×2

index ×1

random ×1

update ×1