2017-10-10 6 views

답변

2

예 데이터 :

insert into car values 
(1, 'brand=>ford, color=>yellow'), 
(2, 'brand=>volvo, mileage=>50000, year=>2015'); 

hstore 열 쌍 (key, value)를 얻을 수있는 기능 each(hstore)를 사용

select id, key, value 
from car, each(fields); 

id | key | value 
----+---------+-------- 
    1 | brand | ford 
    1 | color | yellow 
    2 | year | 2015 
    2 | brand | volvo 
    2 | mileage | 50000 
(5 rows)  

삽입 명령은 다음과 같이 보일 수 있습니다 :

insert into store (car_id, key, value) 
select id, key, value 
from car, each(fields);