PostgreSQL/Array/Array Column — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 10:14, 26 мая 2010
Содержание
Creating a table with a multidimensional array column
postgres=# -- Creating a table with a multidimensional array column
postgres=#
postgres=# CREATE TABLE authors (id integer,titles text[][]);
CREATE TABLE
postgres=#
postgres=# drop table authors;
DROP TABLE
postgres=#
Creating a table with an array column
postgres=# -- Creating a table with an array column
postgres=#
postgres=# CREATE TABLE books (employee_id integer, books text[]);
CREATE TABLE
postgres=#
postgres=#
postgres=# drop table books;
DROP TABLE
postgres=#
Integer array and text array
postgres=# -- Declaration of Array Types
postgres=#
postgres=# CREATE TABLE sal_emp (
postgres(# name text,
postgres(# pay_by_quarter integer[],
postgres(# schedule text[][]
postgres(# );
CREATE TABLE
postgres=# INSERT INTO sal_emp
postgres-# VALUES ("A",
postgres(# "{10000, 10000, 10000, 10000}",
postgres(# "{{"A", "B"}, {"C", "D"}}");
INSERT 0 1
postgres=#
postgres=# INSERT INTO sal_emp
postgres-# VALUES ("B",
postgres(# "{20000, 25000, 25000, 25000}",
postgres(# "{{"Z", "X"}, {"Y", "Q"}}");
INSERT 0 1
postgres=#
postgres=#
postgres=# SELECT * FROM sal_emp;
name | pay_by_quarter | schedule
------+---------------------------+---------------
A | {10000,10000,10000,10000} | {{A,B},{C,D}}
B | {20000,25000,25000,25000} | {{Z,X},{Y,Q}}
(2 rows)
postgres=#
postgres=# drop table sal_emp;
DROP TABLE
postgres=#
Two dimentional array
postgres=# CREATE TABLE t (
postgres(# squares integer[3][3]
postgres(# );
CREATE TABLE
postgres=#
postgres=# \d t;
Table "public.t"
Column | Type | Modifiers
---------+-----------+-----------
squares | integer[] |
postgres=#
postgres=# drop table t;
DROP TABLE
postgres=#