2
我必須創建一個包含用戶定義類型和插入數據的表。如何轉換爲postgresql中的用戶定義類型
我試過這種方式。
- create type type1 as(i int);
- create function mycast(int)返回type1爲'select $ 1;'語言'sql';
- 使用函數mycast(int)創建cast(int爲type1)爲隱式;
- create table table_type(t type1);
- insert into table_type values(1 :: type1);
現在值越來越插入,但包裹在括號中,類似這樣的
select * from table_type;
t
--------
(1)
(1 rows)
我相信有可能是我的功能錯誤。有人可以幫忙嗎?我基本上想要一個函數,它返回與我的輸入相同的輸出(沒有任何())。
謝謝。
+1更快。作爲參考['CREATE DOMAIN'](http://www.postgresql.org/docs/current/static/sql-createdomain.html) –
@Peter謝謝,但我需要使用create type本身。我的要求是測試創建類型語法和用戶定義的類型。 – dspgsql
然後請寫一個問題,描述你實際上想要做的事情。 –