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
然后请写一个问题,描述你实际上想要做的事情。 –