SELECT '20210721'::DATE -> 2021.07.21
SELECT ''||'20210721': :: DATE -> 2021-07-21
이 두개 차이가 먼가요?
데이터 타입이 다릅니다.
두번째는 빈문자열을 붙여서 text 타입으로 바뀌네요.
postgres=# create table t1 as SELECT '20210721'::DATE; SELECT 1 postgres=# \d t1; Table "public.t1" Column | Type | Modifiers --------+------+----------- date | date | postgres=# create table t2 as SELECT ''||'20210721':: DATE; SELECT 1 postgres=# \d t2 Table "public.t2" Column | Type | Modifiers ----------+------+----------- ?column? | text |
postgres=# create table t1 as SELECT '20210721'::DATE;
SELECT 1
postgres=# \d t1;
Table "public.t1"
Column | Type | Modifiers
--------+------+-----------
date | date |
postgres=# create table t2 as SELECT ''||'20210721':: DATE;
postgres=# \d t2
Table "public.t2"
----------+------+-----------
?column? | text |