Monday, November 21, 2011

PostgreSQL Integer Array - Expand Integer Array to Rows


Expand the Integer Array to rows :

SELECT ARRAY[1,2,3]::INT[] AS a

The above query will produce the result as
  a
-----
[1,2,3]

If you wants to expands this integer array to rows by using the in build method UNNEST

SELECT UNNEST(ARRAY[1,2,3]::INT[]) AS a

Now The above query will produce result as 

  a
-----
 1
 2
 3


By this way we can expand the array into rows..

No comments:

Post a Comment