Snowflake의 데이터 타입과 함수
Jake Roach
Field Data Engineer
2023-04-01
YYYY-MM-DD
CREATE TABLE sales (
transaction_date DATE -- Define a column of type `DATE`
);
SELECTTO_DATE('2023-04-01') AS the_date, -- Convert a string into a DATE'2023-04-01'::DATE AS casted_date -- Casted using <value>::DATE;
the_date | casted_date
----------- | ------------
2023-04-01 | 2023-04-01
08:24:08
HH:MM:SS
CREATE TABLE sales (
transaction_time TIME -- Create a column with the `TIME` keyword
);
TIME 열 정의SELECTTO_TIME('08:24:04') AS the_time,'08:24:04'::TIME AS casted_time;
| the_time | casted_time |
| ---------- | ----------- |
| 08:24:08 | 08:24:08 |
TO_TIME 함수::로 캐스팅TIMESTAMP는 날짜와 시간을 모두 포함합니다 2023-04-01 08:24:04
YYYY-MM-DD HH:MM:SS
CREATE TABLE (
transaction_timestamp TIMESTAMP
);
SELECT
TO_TIMESTAMP('2023-04-01 08:24:04') AS the_timestamp,
'2023-04-01 08:24:04'::TIMESTAMP AS casted_timestamp
;
TO_TIMESTAMP 또는 <value>::TIMESTAMP로 변환 the_timestamp | casted_timestamp
--------------------- | ----------------------
2024-04-01 08:24:08 | 2024-04-01 08:24:08
SELECT TO_DATE('2021-05-14') AS the_date, TO_TIME('06:13:00') AS the_time, TO_TIMESTAMP('2021-05-14T06:13:00') AS the_timestamp,-- Extract the DATE from a TIMESTAMP, we could do the same with TIME! transaction_timestamp::DATE AS casted_date;
the_date | the_time | the_timestamp | casted_date
------------ | ----------- | -------------------- | ------------
2021-05-14 | 06:13:00 | 2021-05-14T06:13:00 | 2021-05-14
기본적으로 DATE, TIME, TIMESTAMP는 타임존 없이 저장됩니다
$$
TIMESTAMP_NTZ
TIMESTAMP의 기본 구현$$
TIMESTAMP_LTZ
$$
TIMESTAMP_TZ
Snowflake의 데이터 타입과 함수