PostgreSQL之自定义类型

2016/11/03 PostgreSQL 共 289 字,约 1 分钟

参考

createType

实例

方法一

create table mytype (i bigint,j bigint);
--注意:建表的同时系统会默认建一个同名的自定义类型

方法二

create type mytype as (i bigint,j bigint);

建表

create table mytest (id bigint,val mytype);

插入数据

insert into mytest(id,val) values(1,(2,3)::mytype)

查询

select * from mytest
 
select id,(val).* from mytest
 
select id,(val).i,(val).j from mytest

文档信息

Search

    Table of Contents