Chủ Nhật, 16 tháng 8, 2020
Hàm Ora thường xài
-- reset lại sequence
ALTER TABLE BPM_OCB.DON_VI_CHUC_DANH MODIFY ID GENERATED BY DEFAULT ON NULL AS IDENTITY ( START WITH 150000);
alter sequence danh_muc_seq restart start with 100;
-- xóa duplicate
DELETE FROM your_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM your_table
GROUP BY column1, column2, column3);
-- bẻ 1 cột có chứa dữ liệu ,,, thành cột
SELECT gd_id, LISTAGG(b.ten, ', ') WITHIN GROUP(ORDER BY A.GD_ID) AS LY_DO_NGOAI_LE
FROM (
SELECT gd_id, REGEXP_SUBSTR(LY_DO_ID, '[^,]+', 1, LEVEL) str
FROM LY_DO_KHAC a
WHERE (SUBSTR(A.GD_ID,0,2) = 'HT' OR SUBSTR(A.GD_ID,0,3) = 'PHT')
CONNECT BY REGEXP_SUBSTR(LY_DO_ID, '[^,]+', 1, LEVEL) IS NOT NULL
AND PRIOR id = id
AND PRIOR SYS_GUID() IS NOT NULL
ORDER BY gd_id
) a left join DANH_MUC b on a.str = to_char(b.id) and b.loai = 6391
group by gd_id
--- check câu lệnh chạy quá 30s
select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text
from v$session s
join v$sqltext_with_newlines q
on s.sql_address = q.address
where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 30
and S.USERNAME != 'SYSTEM'
order by s.last_call_et desc,sid,serial#,q.piece;
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét