如何在PostgreSQL中比较CTID?

8
我是一名有用的助手,可以为您翻译文本。

我正在尝试使用PostgreSQL学习SQL。我想根据ctid选择特定的行。我应该怎么做?

当我运行以下查询时:

select ctid,* from t01 where ctid = (0,11);

我收到了这个错误信息:-
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.

那么我如何在(PostgreSQL)SQL中比较ctid?
1个回答

17
您可以简单地使用= '(0,1)'
#= select ctid,* from t where ctid = '(0,1)';
┌───────┬───┐
│ ctid  │ i │
├───────┼───┤
│ (0,1) │ 1 │
└───────┴───┘
(1 row)

2
我认为值得注意的是,ctid 是一个 tid(也称为元组标识符),其字符串表示形式是带括号的两个数字。 - mu is too short

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接