PostgreSQL UUID Syntax Error – How to Resolve

postgresqlsyntaxuuid

Whever I use a UUID as a literal, I get

SELECT a82857b6-e336-4c6c-8499;
ERROR:  syntax error at or near "-"

I thought it might be an encoding issue, but that doesn't seem to be it.

Best Answer

As documented in the manual, string constants (or in general: anything that is not a number) need to be enclosed in single quotes:

ALTER TABLE newarts ALTER COLUMN jurisdiction_id 
   SET DEFAULT 'a82857b6-e336-4c6c-8499-4242';
Related Question