본문 바로가기
DB/Oracle

형식문자

by 태윤2 2020. 6. 23.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- 형식문자를 온전한 영단어로 작성하면 결과도 전체 스펠링으로 출력됨
 
SELECT employee_id, TO_CHAR(hire_date, 'YEAR/MONTH/DAY') month_hired, hire_date
FROM employees
WEHRE last_name ='Higgins';
 
EMPLOYEE_ID MONTH_HIRED                              HIRE_DATE
----------- ---------------------------------------- ---------
        205 TWO THOUSAND TWO/JUNE     /FRIDAY          07-JUN-02
 
- 형식문자를 3/2자리 약어로 작성한 경우 출력 결과도 3자리 약어로 출력됨
 
SELECT employee_id, TO_CHAR(hire_date, 'MON/DY') month_hired, hire_date
FROM employees
WHERE last_name = 'Higgins';
 
EMPLOYEE_ID MONTH_HIRED                              HIRE_DATE
----------- ---------------------------------------- ---------
        205 JUN/FRI                                  07-JUN-02
 
- 형식문자에서 단위의 첫문자를 반복해서 작성하는 형태는 출력결과가 숫자로 출력됨.// 대소문자의 영향을 받지 않는다
 
SELECT employee_id, TO_CHAR(hire_date, 'YYYY/MM/DD') month_hired, hire_date
FROM employees
WHERE last_name = 'Higgins';
 
EMPLOYEE_ID MONTH_HIRED                              HIRE_DATE
----------- ---------------------------------------- ---------
        205 2002/06/07                               07-JUN-02
 
- 스펠링으로 출력되는 형태의 형식문자의 대소문자는 출력되는 문자에서도 유지된다.
 
SELECT employee_id, To_CHAR(hire_date, 'Year/Month/Day') month_hired, hire_date
FROM employees
WHERE last_name = 'Higgins';
 
EMPLOYEE_ID MONTH_HIRED                              HIRE_DATE
----------- ---------------------------------------- ---------
        205 Two Thousand Two/June/Friday            07-JUN-02
 
 
cs

"

'DB > Oracle' 카테고리의 다른 글

TO_CHAR,NUMBER,DATE  (0) 2020.06.23
시간 형식 문자  (0) 2020.06.23
함수  (0) 2020.06.23
단일 행 함수(Single-row Function) - 수정  (0) 2020.06.05
WHERE(조건문) 과 ORDER BY (정렬) 절  (0) 2020.06.04