2017-05-07 23 views
-3

我正在查詢我的Postgres db中的uuid。這裏是我的表模式:如何在postgres中查詢特定的uuid?

 Column  |  Type  |    Modifiers    
----------------------+-----------------+------------------------------------- 
casefile_id   | uuid   | not null default uuid_generate_v1() 
org_id    | uuid   | 
casefile_template_id | uuid   | 
casefile_status  | casefile_status | 

我嘗試用

select * from casefile where casefile_id = 'e0da8698-32e6-11e7-a8de-985aeb8b64f';

查詢並且得到錯誤:

ERROR: invalid input syntax for uuid: "e0da8698-32e6-11e7-a8de-985aeb8b64f"

然後我期待在SO,看看這句法:

select * from casefile where casefile_id = ANY('{e0da8698-32e6-11e7-a8de-985aeb8b64f}');

但仍然得到錯誤:

ERROR: invalid input syntax for uuid: "e0da8698-32e6-11e7-a8de-985aeb8b64f"

我缺少什麼?我如何過濾UUID?爲什麼我不能像查詢其他主鍵那樣查詢?

+0

你使用的是什麼版本的Postgres? –

+0

你是如何填充這張桌子的? –

+0

9.5.2。我用'express'端點填充表格。 uuid是在UUID PRIMARY KEY DEFAULT uuid_generate_v1()表上使用此數據類型創建的。 – jhamm

回答

2

你有錯誤的UUID - 它錯過了最後一個符號組中的一個符號