2017-06-14 172 views
0

我創建的Postgres SQL視圖與SQL語句創建視圖的Postgres SQL與評論

CREATE OR REPLACE VIEW {ViewName} as 
Select 
..... 

我問有沒有什麼方法來創建視圖的列註釋。 創建視圖後,它生成時的註釋被添加到列的錯誤:

ERROR: "{ViewName}" is not a table, composite type, or foreign table.

+1

請分享完整的陳述,或至少評論youwant –

+0

的顯示例子是什麼產生錯誤的SQL語句? –

+0

創建或更換視圖{ViewName}爲 選擇 column1, column2, .... – IvoAtanasov

回答

2

要定義上一列(或一視圖)註釋使用comment on

create view some_view 
as 
select x as col1, y as col2, z as col3 
from some_table; 

然後:

comment on view some_view is 'Some View'; 
comment on column some_view.col1 is 'Originally column X'; 
+0

好吧我設法添加對視圖本身的評論,但我得到一個錯誤 錯誤:跨數據庫引用未實現:「some_view.col1」 – IvoAtanasov

+0

@IvoAtanasov:這是一個完全不同的問題,只有當您向我們展示您正在使用的** reall **和** complete **聲明時才能回答。但你應該爲此創建一個[新問題](https://stackoverflow.com/questions/ask)。 –

+0

它的工作我只是拼錯我的專欄名稱,對不起。感謝@a_horse_with_no_name – IvoAtanasov