David Masip
David Masip

Reputation: 2491

No filter for uuid in postgresql

I want to do a filter in SQL where no value of an uuid is matched. That is, a where condition where no row is matched by the condition.

With a regular int4 id, I would do:

where my_id = -1

If I do the same thing with the uuid, I get:

where my_uuid = '-1'

I get an error:

ERROR: invalid input syntax for type uuid: "-1"

How can I do this with an uuid? I would need to use a =, so solutions of the form

where my_uuid is null

don't work for me. Thanks in advance!

Upvotes: 0

Views: 1368

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246238

What about

'00000000-0000-0000-0000-000000000000'::uuid

That is just as good an "impossible value" as -1 is for an integer (both are not really impossible).

Upvotes: 2

Related Questions