Mega Code Archive

 
Categories / PostgreSQL / Array
 

Selecting From a Multi-Dimensional Array

postgres=# postgres=# CREATE TABLE authors (id integer,titles text[][]); CREATE TABLE postgres=# postgres=# INSERT INTO authors postgres-#              VALUES (102, postgres(#              '{{"J T", "T S"}, postgres'#                {"C D", "G E"}, postgres'#                {"A D", "A L"}}'); INSERT 0 1 postgres=# postgres=# -- Selecting From a Multi-Dimensional Array postgres=# postgres=# SELECT titles[1][1] AS author, titles[1][2] AS title FROM authors;  author | title --------+-------  J T    | T S (1 row) postgres=# postgres=# drop table authors; DROP TABLE postgres=# postgres=#