Search code examples
sqlpostgresqlcomparison

how to compare ctid in postgresql?


I am trying to learn SQL with postgresql . I want select specific row with respected ctid . how can I do that ?

when I ran following query :-

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

I get this error :-

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.

So how can I compare ctids in (postgre)sql ?


Solution

  • You can simply use = '(0,1)':

    #= select ctid,* from t where ctid = '(0,1)';
    ┌───────┬───┐
    │ ctid  │ i │
    ├───────┼───┤
    │ (0,1) │ 1 │
    └───────┴───┘
    (1 row)