티스토리 뷰
17년 2월 기준.
to_char(to_timestamp(createtime/1000), 'YYYY/MM/DD HH24:MI:SS')
// bitint date타입 변환
SELECT * FROM TABLE_NAME LIMIT 10;
// 처음 10개의 Row를 반환
SELECT * FROM TABLE_NAME LIMIT 10 OFFSET 0;
// 처음(OFFSET 0) 10개의 Row를 반환
SELECT * FROM TABLE_NAME LIMIT 10 OFFSET 10;
// 11번째 부터 10개의 Row를 반환
TO_CHAR(STARTTIME,'YYYY/MM')
column "stat_call_hour.starttime" must appear in the GROUP BY clause or be used in an aggregate function
GROUP BY CONCAT(TO_CHAR(STARTTIME,'YYYY/MM'))
// SELECT 하는 것만큼 GROUP BY 해야 한다.
select status from (
select 1 status from user where id = 'admin' and password = 'admin'
union all
select 2 status from user where id = 'admin'
union all
select 3 status
)a limit 1;
// 아이디 패스워드 맞으면 1, 패스워드 틀리면 2, 다 틀리면 3
select session_user, current_user;
// 세션 유저, 현재 유저 확인
select nextval('rps_cluster_info_seq');
// sequence 값 증가.
select currval('rps_cluster_info_seq');
// sequence 값 받아오기. nextval 실행해서 세션을 얻어야 실행된다.
select setval('rps_cluster_info_seq', 1);
// sequence 값 초기화.
select extract(epoch from now())::bigint
// bigint로 현재 시간 받기
select * from alert where createtime<extract(epoch from now()-interval '1 day')::bigint*1000;
// bigint 비교시 변환후 * 1000을 해야 됨. now()에서 간격조절은 -interval로 가능
select TO_CHAR(TO_TIMESTAMP(bigint_field / 1000), 'DD/MM/YYYY HH24:MI:SS')
// bigint를 timestamp로 변환
pg_dump.exe --file "../backup/stat_call_hour" --host "192.168.100.239" --port "5435" --username "postgres" --no-password --verbose --format=c --blobs --table "public.stat_call_hour" "WebNmsDB"
// pg_dump로 db 백업
'Study' 카테고리의 다른 글
| Windows 10(윈도우 10) Error code(오류 코드) 0x8007007b (0) | 2024.02.14 |
|---|---|
| KeePass(키패스) 관련 (1) | 2024.02.11 |
| Linux(리눅스) Mail(메일) 관련 (1) | 2024.02.07 |
| Edge(엣지) 관련 (0) | 2024.02.07 |
| Firebase(파이어베이스) SDK 설치 관련 (0) | 2024.02.07 |