ข้ามไปยังเนื้อหา

Lesson 15 — Database Storage Overview (ภาษาไทย)

🧠 ภาพจำก่อนอ่าน: 🗄️ Data → ⚙️ Process → 🩺 Health
🎨 Visual Guide ของวิชานี้ — ภาพช่วยจำ ไม่แทนคำสั่งและเนื้อหาจริง

Storage index · Lab 09

Oracle University 19c Administration Workshop Lesson 15 mapped by source inventory. Original Thai teaching reconstruction; not page-verified against proprietary Student Guide. Static authored; no Oracle live run. 19c foundation with 26ai documentation as current reference.

เข้าใจ Logical vs Physical Storage พร้อมวิเคราะห์ Oracle storage problems อย่างเป็นลำดับ ไม่แก้ด้วยการเพิ่ม datafile หรือเปลี่ยน initialization parameters โดยไม่มีหลักฐาน.

flowchart TB
 DB[(Oracle Database)] --> TS[Tablespace: logical storage]
 TS --> SEG[Segment]
 SEG --> EXT[Extent]
 EXT --> BLOCK[Data blocks]
 TS --> DF[(Datafiles: physical storage)]
 DF --> OS[Filesystem / ASM Disk Group]

Database → Tablespace → Segment → Extent → Data Block. Datafiles are physical storage for tablespaces. Control files and redo files have separate recovery roles.

Operational distinction: Logical space, allocated bytes, recoverable/reclaimable segment space, autoextend maximum, and free filesystem/ASM capacity are separate measurements. A single percent-used number is insufficient to decide a resize.

ประเด็น ต้องตรวจ ตัดสินใจอย่างไร
Capacity bytes, free, maxbytes, autoextend หา bottleneck จริงก่อนขยาย
Container scope current CDB/PDB, datafile scope ห้ามเปลี่ยน object ผิด tenant
Performance I/O pressure, segment growth, transactions วิเคราะห์ช่วงเวลาและ workload
Recovery archive/backup and rollback ตรวจ restore proof ก่อน DDL

ต้องมี approved SELECT privileges. DBA_* views แสดงตาม container/role; output อาจรวม path ที่ sensitive — ห้ามเผยแพร่ path ภายในแบบไม่ redact.

SHOW CON_NAME
SELECT tablespace_name,contents,status FROM dba_tablespaces ORDER BY tablespace_name;

ตรวจว่าเป็น permanent, temporary, undo หรือ application tablespace; เก็บ timestamp และเทียบย้อนหลัง ถ้าดูแค่ DBA_FREE_SPACE จะพลาด autoextend headroom, temp และ underlying storage capacity. เมื่อ SQL เจอ ORA-00942/ORA-01031 ให้ขอ grant เฉพาะ view แทนการ grant DBA.

Do not conflate segment free space with filesystem free space; understand CDB/PDB scope and ASM/OMF path semantics.

  1. เก็บ exact ORA error, time, SQL/workload, affected schema and PDB.
  2. ตรวจ class of tablespace, file allocations, free extents, maxbytes and actual filesystem/ASM free.
  3. ตรวจ application growth, long transactions, backup/archiving and alert log.
  4. แยก emergency mitigation จาก root-cause fix; เขียน impact/rollback แล้วขอ change approval.
  5. ทำ post-change verification และติดตาม trend ไม่ตัดสินจาก snapshot เดียว.
  • อธิบายเหตุที่ DBA_DATA_FILES.BYTES ไม่เท่ากับ used space ของ table.
  • อธิบายข้อแตกต่าง free extents vs unused blocks below HWM.
  • ทำ capacity worksheet: allocated, max autoextend, storage free, projected growth, escalation threshold.
  • ระบุสิ่งที่จะต้อง rollback/restore หากมีการเปลี่ยนแปลง.
  1. ถ้าพื้นที่ database เต็ม แต่ filesystem ยังเหลือ จะตรวจอะไร?
  2. ถ้า autoextend ON แต่ MAXBYTES เท่าปัจจุบัน มี headroom จริงหรือไม่?
  3. ถ้า PDB ต้องใช้ quota จะตรวจ owner และสิทธิ์อะไร?
  4. ทำไม DELETE อาจไม่ทำให้ disk usage ลดทันที?
  5. ปัญหา space สามารถเกิดร่วมกับ undo/redo/backup ได้อย่างไร?

Oracle lesson 15 ต้องอธิบายหน้าที่ของ default tablespaces: SYSTEM เก็บ core dictionary, SYSAUX เก็บ auxiliary components, TEMP ใช้ temporary operations, UNDO รองรับ read consistency และ rollback, USERS เป็น default user-data tablespace ในหลาย DBCA templates (ไม่ใช่การรับรองว่ามีชื่อ USERS ในทุก environment). ต้องรู้ว่า tablespace ≠ datafile และ undo/redo ไม่ใช่สิ่งเดียวกัน.

Oracle Data Block เป็นหน่วยเก็บข้อมูลบน database; block size เลือกตาม database design และข้อจำกัด platform. การอ่าน table เป็น blocks/segment extents กระทบ I/O, row chaining/migration และ buffer cache.

Deferred segment creation: Oracle อาจสร้าง table metadata ก่อน โดยยังไม่ allocate segment/data extent จนมี insert ตาม config และ object type. ดังนั้น table object ที่มีอยู่ใน DBA_TABLES อาจยังไม่ปรากฏใน DBA_SEGMENTS; ไม่ใช่ corruption โดยอัตโนมัติ.

-- Read-only (requires DBA views)
SELECT owner,table_name,segment_created FROM dba_tables
WHERE owner='LAB_OWNER' ORDER BY table_name;
SELECT owner,segment_name,segment_type,tablespace_name
FROM dba_segments WHERE owner='LAB_OWNER' ORDER BY segment_name;

คำถาม: ตารางเปล่าที่ไม่มี segment กับตารางที่เคยมีข้อมูลแล้ว DELETE จนหมด ใช้พื้นที่เหมือนกันหรือไม่? ทำไม?

✅ บทที่ 15/31 ในเส้นทางหลัก

เมื่ออ่านและฝึกทบทวนจบแล้ว ทำเครื่องหมายเพื่อบันทึกใน Browser นี้