Chủ Nhật, 27 tháng 12, 2020

Backup và Recovery của Container Database (CDB) và Pluggable Database (PDB) trong Oracle Database 12c/18c/19c/21c

NỘI DUNG
1. KẾT NỐI TỚI RMAN
2. BACKUP
Container Database (CDB) Backup
Root Container Backup
Pluggable Database (PDB) Backup
Tablespace và Datafile Backups
Archived Redo Log Backups

3. RECOVERY ĐẦY ĐỦ
Root Container Complete Recovery
Pluggable Database (PDB) Complete Recovery
Tablespace and Datafile Complete Recovery

4. POINT IN TIME RECOVERY (PITR) (KHÔNG ĐẦY ĐỦ)
Container Database (CDB) Point In Time Recovery (PITR)
Pluggable Database (PDB) Point In Time Recovery (PITR)
Table Point In Time Recovery (PITR) in PDBs

1. KẾT NỐI TỚI RMAN
Kết nối tới root container trong CDB với quyền "AS SYSDBA":
$ export ORAENV_ASK=NO
$ export ORACLE_SID=cdb1
$ . oraenv
The Oracle base remains unchanged with value /u01/app/oracle
$ export ORAENV_ASK=YES

$ rman target=/
Recovery Manager: Release 12.1.0.1.0 - Production on Sun Dec 22 17:03:20 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CDB1 (DBID=797615285)

RMAN>
Sửa bài viết

Thứ Bảy, 12 tháng 12, 2020

Tự động Add partition cho bảng partition trong Oracle Database

Vấn đề: Đối với các bảng dữ liệu có đánh partition theo tháng hoặc theo ngày, người DBA thường xuyên phải đánh partition, nếu quên dữ liệu insert vào sẽ bị lỗi và có thể dẫn đến lỗi toàn hệ thống.

– Giải pháp: Để giải quyết vấn đề trên ta thường viết thủ tục đánh partition tự động cho bảng và đặt scheduler để chạy định kỳ. Việc đánh partition không ảnh hưởng tới các thao tác insert, select, update, delete.
Sửa bài viết

Bí quyết move partition bảng Core tối thiểu thời gian downtime trong Oralce Database

Mục đích: Với bảng core khi move partition mà không rebuild luôn index partition làm cho các câu lệnh Insert, update, delete sẽ bị lỗi, câu lệnh select thì sẽ bị quét full do đó với bảng Core các bạn cần chú ý khi move 1 partition thì phải rebuild index luôn và check luôn unusable nhé.

1. Script sinh câu lệnh:
select 'alter table '||table_owner||'.'||table_name||' move partition '||partition_name|| ' tablespace ' || substr(partition_name,1,8) ||'_RW nologging parallel 4;', partition_name, tablespace_name 
from dba_tab_partitions
where table_owner='BINH_OWNER' and table_name = 'TAB1' and partition_name like 'DATA2014%'
union
select 'alter index '||index_owner||'.'||index_name||' rebuild partition '||partition_name
|| ' tablespace INDX' || substr(partition_name,5,4) || '_RW nologging parallel 4 online;', partition_name, tablespace_name 
from dba_ind_partitions
where index_name in
    (select index_name from dba_indexes where
    table_owner='BINH_OWNER' and table_name = 'TAB1')
    and partition_name like 'DATA2014%'
union
select 'alter index '||owner||'.'||index_name||' noparallel;', null, null from dba_indexes where
table_owner='BINH_OWNER' and table_name = 'TAB1'
order by 2, 1 desc, 3;

2. Copy vào TOAD hoặc SQL Navigator để chạy .
 
3. Check lại:
select * from dba_ind_partitions where status='UNUSABLE';

KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH: 📧 Mail: binhoracle@gmail.com ☎️ Mobile: 0902912888 ⚡️ Skype: tranbinh48ca 👨 Facebook: https://www.facebook.com/BinhOracleMaster 👨 Inbox Messenger: https://m.me/101036604657441 (profile) 👨 Fanpage: https://www.facebook.com/tranvanbinh.vn 👨 Inbox Fanpage: https://m.me/tranvanbinh.vn 👨👩 Group FB: https://www.facebook.com/groups/OracleDBAVietNam 👨 Website: http://www.tranvanbinh.vn 👨 Blogger: https://tranvanbinhmaster.blogspot.com 🎬 Youtube: http://bit.ly/ytb_binhoraclemaster 👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi 👨 Linkin: https://www.linkedin.com/in/binhoracle 👨 Twitter: https://twitter.com/binhoracle 👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội #OracleTutorial #OracleDBA #OracleDatabaseAdministration #học oracle database #oca #ocp #oce #ocm Sửa bài viết

Thứ Năm, 10 tháng 12, 2020

Cách tạo FUNCTION INDEX trong Oracle Database


1. Tạo index tăng tốc độ truy vấn tên nhân viên:
Câu lệnh:
SELECT * FROM emp WHERE UPPER(emp_name) LIKE 'JOH%';

Tạo index:
CREATE INDEX idx ON emp (UPPER(emp_name));

Câu lệnh
SELECT id, geo, area(geo), desc
     FROM rivers     
     WHERE area(geo) >5000

Tạo index:
CREATE INDEX area_index ON rivers (area(geo));
Sửa bài viết

Cách tạo FUNCTION INDEX trong Oracle Database


1. Tạo index tăng tốc độ truy vấn tên nhân viên:
Câu lệnh:
SELECT * FROM emp WHERE UPPER(emp_name) LIKE 'JOH%';

Tạo index:
CREATE INDEX idx ON emp (UPPER(emp_name));

Câu lệnh
SELECT id, geo, area(geo), desc
     FROM rivers     
     WHERE area(geo) >5000

Tạo index:
CREATE INDEX area_index ON rivers (area(geo));
Sửa bài viết

Cơ chế làm việc của Index trong Oracle Database

B-Tree indexes (sau đây gọi là index) là một object có cấu trúc, chúng ta có thể coi nó như là 1 table cũng được. Tuy nhiên chúng được sắp xếp theo dạng B-Tree (cây nhị phân) để phục vụ cho việc tìm kiếm nhanh. Nó bao gồm các thông tin sau: 

- Index key: chứa các trường dữ liệu làm key khi tạo index 

- RowID: là ROWID tương ứng với dòng dữ liệu chứa index key. 
Sửa bài viết

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master