TYPE type_name是PostgreSQL中Oracle的VARCHAR2(64)的数字索引表 [英] TYPE type_name IS TABLE OF NUMBER INDEX BY VARCHAR2(64) from Oracle in PostgreSQL

查看:130
本文介绍了TYPE type_name是PostgreSQL中Oracle的VARCHAR2(64)的数字索引表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PostgreSQL中是否有与Oracle中相同的类型声明:

Is there an equivalent type declaration in PostgreSQL to this one in Oracle:

TYPE type_name IS TABLE OF OBJECT

我有一个类型:

CREATE TYPE t_pick AS
(
    bet_no  integer,
    result  smallint
);

现在我想使用此类型创建表。在Oracle中,我使用上述声明进行了此操作。但是如何在PostgreSQL中执行此操作?

还是还有其他方法?

And now I want to create table using this type. In Oracle I did this with a declaration like above. But how to do this in PostgreSQL?
Or is there another way?

推荐答案

您无法定义数组

但是您可以创建一个复合类型,然后在数组中使用它:

You cannot define array types or collection types in PostgreSQL.
But you can create a composite type and then use it in an array:


CREATE TYPE t_pick AS
( 
  bet_no integer;
  result smallint;
);

CREATE OR REPLACE FUNCTION foo ..

DECLARE 
  var t_pick[];
BEGIN
 ...

这篇关于TYPE type_name是PostgreSQL中Oracle的VARCHAR2(64)的数字索引表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆