반응형
/********************************************************************************************
-- Title : [PGS9.2] Convert Data Type
-- Reference : dbrang.tistory.com
-- Key word : data type 데이터 타입 형 변환
********************************************************************************************/
-- Can convert data type using "CONVERT()" or "{data}::TYPE"
-- Title : [PGS9.2] Convert Data Type
-- Reference : dbrang.tistory.com
-- Key word : data type 데이터 타입 형 변환
********************************************************************************************/
-- Can convert data type using "CONVERT()" or "{data}::TYPE"
create table ttt(a int, b varchar(10), c text);
insert into ttt values
(1, 'aaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
(2, 'bbbbbbbbbb', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'),
(3, 'cccccccccc', 'cccccccccccccccccccccccccccccccccccccccccccccccccc');
select a, b::text || ' ' ||c "dd"
from ttt;
select cast(a as varchar(10)) || ' ' || b || ' ' || c
from ttt;
select a::varchar(10) || ' ' || b || ' ' || c
from ttt;
select a::text || ' ' || b::text || ' ' || c::text
from ttt;
반응형