Skip to content

Instantly share code, notes, and snippets.

@dizballanze
Created January 17, 2015 18:15
Show Gist options
  • Save dizballanze/af1caf10c3b6fae19147 to your computer and use it in GitHub Desktop.
Save dizballanze/af1caf10c3b6fae19147 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