Professional Documents
Culture Documents
http://class.svuca.edu/~d.liang/
(dongming.liang@svuca.edu) Silicon Valley University Dr. Dongming Liang
Agenda
Segment types Control block space usage Manage table data Structure of a row
Overview
Segments
If the column is large, the Oracle server stores these values in separate segments known as LOB segments The table contains only a locator or a pointer to the location of the corresponding LOB data
13
This segments helps to initialize the data dictionary cache when the database is opened by an instance Bootstrap segment cannot be queried or updated
Does not need any maintenance by DBA
14
Question
Given a table created by Create Table T(
ID number Primary Key, name varchar2(100), phone number, addr varchar2(50), video CLOB); Question: How many segments do you have for this table?
15
Extents
16
Blocks
19
Database Block
Minimum unit of I/O Consists of one or more OS blocks Set at tablespace creation DB_BLOCK_SIZE is the default block size
20
21
23
24
Example: DBA_Segments
Get # of extents and blocks allocated to a segment
25
Example: DBA_Extents
Check the extents for a given segment
26
Tables
27
28
29
30
ROWID
ROWID is a unique identifier for each row in the database ROWID is not stored explicitly as a column value ROWID can be queried along with other columns in a table ROWID provides the fastest means of accessing a row in a table
31
ROWID Format
Data object number is assigned to each data object, such as table or index (unique within the database) Relative file number is unique to each file within a tablespace Block number represents block position Row number identifies row position in a block
32
ROWID Example
33
Structure of a Row
Row data is stored in DB blocks as variable-length records Row header: number of columns, chaining info, and row lock status Row data: column length and value
34
Create a Table
35
PCTFREE: reserve 30% of each block for updates and allows inserts of new rows to fill a maximum of 70% of each block PCTUSED: a block becomes a candidate for row insertion when its used space falls below 50%
36
Tables retain data only for the duration of a transaction or session DML locks are not acquired on the data DMLs do not generate redo logs Can create indexes, views, and triggers on temporary tables
37
Truncate a Table
Truncate Table employees; Truncating a table deletes all rows in a table and release used space Corresponding indexes are truncated No undo data is generated (it is a DDL)
38
Drop a Table
DROP TABLE departments A table may be dropped if it is no longer needed or if it is to be reorganized
39
Drop a Column
Remove a column from a table
Remove the column length and data from each row, freeing space in the data block Dropping a column in a large table takes a considerable amount of time A checkpoint occurs every 1000 rows
40
41
Example: DBA_TABLES
42
Example: DBA_OBJECTS
43
Summary
Segments types Create regular and temporary tables Outline the structure of a row Create/drop/truncate table
44