Skip to content

Instantly share code, notes, and snippets.

@serebro
Forked from dizballanze/queries.sql
Last active August 29, 2015 14:13
Show Gist options
  • Save serebro/950ff440782a81e3f1bc to your computer and use it in GitHub Desktop.
Save serebro/950ff440782a81e3f1bc to your computer and use it in GitHub Desktop.
CREATE TYPE address AS (country text, city text, zip varchar(6), street text, number text, building text);
CREATE TABLE users (id SERIAL PRIMARY KEY, email text, adresses address[]);
INSERT INTO users(email, adresses) VALUES('user1@example.org', ARRAY[ROW('RU', 'Moscow', '123123', 'Lenina', '5', 'a')::address, ROW('RU', 'SPB', '123456', 'Gagarina', '102', '5')::address]);
SELECT * FROM users;
id | email | adresses
----+-------------------+--------------------------------------------------------------------
1 | user1@example.org | {"(RU,Moscow,123123,Lenina,5,a)","(RU,SPB,123456,Gagarina,102,5)"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment