如何比较postgresql中的ctid?

4 sql postgresql comparison

我正在尝试使用 postgresql 学习 SQL。我想选择具有受人尊敬的 ctid 的特定行。我怎样才能做到这一点 ?

当我运行以下查询时:-

select ctid,* from t01 where ctid = (0,11);
Run Code Online (Sandbox Code Playgroud)

我收到此错误:-

operator does not exist: tid = record
LINE 1: select ctid,* from t01 where ctid = (0,11)
                                          ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

那么如何比较 (postgre)sql 中的 ctids 呢?

Mar*_*rth 9

您可以简单地使用= '(0,1)'

#= select ctid,* from t where ctid = '(0,1)';
?????????????
? ctid  ? i ?
?????????????
? (0,1) ? 1 ?
?????????????
(1 row)
Run Code Online (Sandbox Code Playgroud)

  • 我认为值得注意的是 `ctid` 是一个 [`tid` (又名元组标识符)](https://www.postgresql.org/docs/current/static/datatype-oid.html),其字符串表示形式是括号中的一对数字。 (2认同)