我很好奇这个语句是如何在 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) 有没有办法让这个唯一索引允许重复的行?我想也许有一些额外的空格字符,但我找不到它们。
=> 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)