I have a DB table that someone else created, its PK is a single column of type 'uuid'. I'm struggling to perform a simple select by that column. Examples I have tried with no success:

select from site where id = "9d4da323-4c20-360f-bd9b-ec54feec54f0"

select from site where id = UUID('9d4da323-4c20-360f-bd9b-ec54feec54f0')

select from site where id::text = '9d4da323-4c20-360f-bd9b-ec54feec54f0'

what's the right syntax?

  • 1
    The last two work just fine: rextester.com/XSTGL91416 UUID('9d4da323-4c20-360f-bd9b-ec54feec54f0') is the same as '9d4da323-4c20-360f-bd9b-ec54feec54f0'::uuid
    – user1822
    Jul 9, 2018 at 19:12

1 Answer 1


A colleague enlightened me: it was the double quotes around the string literal. The right syntax is:

select from site where id = '9d4da323-4c20-360f-bd9b-ec54feec54f0'

I'm answering my own question, hoping that this helps someone else in the future.


Not the answer you're looking for? Browse other questions tagged or ask your own question.