PostgreSQL学习篇9.13 复合类型

复合类型定义:
postgres=# create type complex as(r double precision,i double precision);
CREATE TYPE
postgres=# create type persion as(name text,age int,sex boolean);
CREATE TYPE
postgres=#
使用复合类型创建表:
postgres=# create table testfh(id complex,people persion);
CREATE TABLE
postgres=#

postgres=# insert into testfh values ((1,2),('李明','27','1'));
INSERT 0 1
postgres=# select * from testfh;
  id   |   people   
-------+-------------
 (1,2) | (李明,27,t)
(1 row)

postgres=# select (people).name from testfh;
 name
------
 李明
(1 row)
postgres=# update testfh set people.name='李大明';
UPDATE 1
postgres=# select (people).name from testfh;
  name 
--------
 李大明
(1 row)

postgres=#

 

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...