Work/PostgreSQL

줄->열 변환

Elick 2011. 4. 20. 15:12
Postgresql 의 특성 중 하나가 배열처리인 것 같다.
아래처럼 경악스러운 기능이 있다.
-----------------------------------------
-bash-3.2$ psql
비밀번호:
Welcome to psql 8.1.22 (server 9.0.3), the PostgreSQL interactive terminal.
 
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
 
WARNING:  You are connected to a server with major version 9.0,
but your psql client is major version 8.1.  Some backslash commands,
such as \d, might not work properly.
 
postgres=#
postgres=#
postgres=# select unnest(string_to_array('111,222,333,444,555', ','));
 unnest
--------
 111
 222
 333
 444
 555
(5건 있음)
postgres=#
-----------------------------------------

이렇게 놀라운 기능이란... 0_0