with
upsert
as
(select 20 as user_id,'aaa' as hidden_columns, 50 as rows, 'bbb' as key, 'ccc' as default_columns),
update_option
as
(update config.users_info as u1 set hidden_columns = 'aaa',default_columns = 'ccc'
from upsert where user_id = upsert.user_id and key = upsert.key)
insert into config.users_info
select upsert.user_id, upsert.hidden_columns, upsert.rows, upsert.key, upsert.default_columns
from upsert where not exists(select 1 from config.users_info where user_id = upsert.user_id and key = upsert.key );
'DB스토리 > POSTGRESQL' 카테고리의 다른 글
PostgreSQL 날짜 연산 (0) | 2018.03.23 |
---|---|
다중로우 배열로 변경 처리 (0) | 2018.01.30 |
Postgresql 9.3. 산술 함수와 연산자 (0) | 2017.02.12 |
postgresql 메뉴얼 사이트 (0) | 2017.01.20 |
PostgreSQL 문자열 함수와 연산자 (0) | 2017.01.20 |