Search Postgresql Archives

Re: Arrays of records?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

you can test it. PostgreSQL 8.3 supports it.

postgres=# CREATE TYPE at AS (a integer, b integer);
CREATE TYPE
postgres=# CREATE TABLE foo(a at[]);
CREATE TABLE
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at]);
INSERT 0 1
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at, (20,30)::at]);
INSERT 0 1
postgres=# SELECT * FROM foo;
          a
-----------------------
{"(10,20)"}
{"(10,20)","(20,30)"}
(2 rows)

postgres=# SELECT a[1] FROM foo;
   a
---------
(10,20)
(10,20)
(2 rows)

postgres=# SELECT a[1].a FROM foo;
a
----
10
10
(2 rows)

regards

Pavel Stehule




2007/7/7, Chris Travers <chris@xxxxxxxxxxxxxxxxxx>:
Hi all;

I was wondering how one would define an array of complex data types or
records.  Any ideas or is this simply not supported?

Best Wishes,
Chris Travers

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux