Structured Types, Oids and Reference Types

From: Craig Anslow <craig(at)mcs(dot)vuw(dot)ac(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Structured Types, Oids and Reference Types
Date: 2002-10-04 08:15:14
Message-ID: 200210042015.14049.craig@mcs.vuw.ac.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I would like to know if anyone could answer my questions:

-------------------------------------------------------------------------------------
Structured Types
-------------------------------------------------------------------------------------
1) What collection types does PostgreSQL support, i.e. lists, arrays, setof
and bagof?

As far as I can see it supports arrays and multidimensional arrays. It also
supports setof(type) as a return type in a function.

e.g.
CREATE TABLE Class (CourseId char(7), Year char(2), Students text[]);

However below does not work with setof(text):

CREATE TABLE Class_Nest(CourseID char(7), Year char(2), Students setof(text));

2) How to iterate through the collection type? Which is I presume is just
arrays.

I can currently only access one element at a time in the array but would like
to know how to iterate through an array?

3) What set oriented operations ( i.e. IN, SUBSET, UNION, INTERSECT,
EXCEPT...) are allowed on the collection types (i.e. lists, arrays, setof and
bagof)?

I can't get anyone them to work on a collection type of an array.

-------------------------------------------------------------------------------------
Oids and Reference Types
-------------------------------------------------------------------------------------
1) Does PostgreSQL support tuple AND table oids? I believe tuple oids are like
unique ids for each row in a table/relation. However I am confused over what
a table oid is. Is a table oid an identifier for a complete table/relation?
e.g. if there were three tables A,B, and C then we could assign 3 different
oids to them say 1,2, and 3 respectively.

2) Can you dereference tuples or columns in a query by using a "deref"
function (DEREF is a keyword) for '.' or C type syntax '->'. i.e

select e.Job->jobid
from Employee e;

or

select e.deref(Job).jobid
from Employee e;

I can't seem to get either option to work.

Cheers Craig
Email: craig(at)mcs(dot)vuw(dot)ac(dot)nz

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Siva Kumar 2002-10-04 08:17:55 Query optimization
Previous Message Shridhar Daithankar 2002-10-04 08:00:54 Re: [HACKERS] Large databases, performance