2013-02-04 25 views
2

我無法從表中選擇包含在類型框中列的查詢的pgsql 9.1訂購boxcolumn PostgreSQL中

create table test (t box); 
CREATE TABLE 
select * from test order by t; 
ERROR: could not identify an ordering operator for type box 
LINE 1: select * from test order by t; 
            ^
TIP: Use an explicit ordering operator or modify the query. 

我想通了,有一類的運營商(box_ops)應照顧排序和平等,甚至試圖爲列創建一個明確的索引。

create index testx on test using gist (t box_ops); 
CREATE INDEX 

但問題仍然存在。我錯過了什麼? 謝謝!

+0

什麼結果,你想達到什麼目的?如果你成功了,你創建的桌子應該是什麼樣子? –

+0

問題是關於排序框列是postgresql – alexdba

回答

1

您必須明確指定一個操作符。例如:

SELECT * FROM test ORDER BY t USING &< 

您必須決定實際需要的順序並選擇相應的比較運算符。

box_ops定義的運營商可在http://www.leadum.com/downloads/dbscribe/samples/postgresql/web_modern/opclass/main/1325676015.html

參見:http://www.postgresql.org/docs/current/interactive/functions-geometry.html

+0

謝謝,它解決了部分問題!現在我只需要進一步:當我在一個包含box行的表中選擇一個聯合時,即使我沒有對這些行進行排序或分組,我也會得到操作錯誤。有沒有辦法讓我指定運算符pgsql是隱式使用的? – alexdba