Integer array and text array : Array Column « Array « PostgreSQL






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=#
           
       








Related examples in the same category

1.Two dimentional array
2.Creating a table with an array column
3.Creating a table with a multidimensional array column