Tải bản đầy đủ (.pptx) (26 trang)

Quản trị cơ sở dữ liệu Oracle 09 oracle storage

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (121.99 KB, 26 trang )

Oracle storage


Tổng quan về tablespace và datafile



Dữ liệu được lưu trữ luận lý trong segment (thông thường là table), và lưu trữ vật
lý trong datafile.



Một tablespace có thể chứa nhiều segment và được tạo thành từ nhiều datafile.


Mô hình lưu trữ dữ liệu Oracle


Operating system block




is the basic unit of I/O for file system
is the minimum unit of data that the operating system can read or write


Datafile





A datafile can be associated with only one tablespace and only one database
A datafile is physically made up of a number of operating system blocks.


Segments, Extents, Blocks, and Rows






A segment is a set of extents that contains all the data for a specific logical
storage structure within a tablespace
Every segment is comprised of one or more extents
An extent consists of a set of consecutively numbered blocks.
A data block is the smallest unit of data, Oracle Database stores data in data
blocks


The relationships among segments, extents, and data blocks


Tablespaces





Each tablespace in an Oracle database consists of one or more files called

datafiles.
Tablespaces store Oracle database objects such as tables, indexes and rollback
segments.
A tablespace can belong to only one database at a time

Database
Tablespace

Data files


Create and Manage Tablespaces

create tablespace tbs_user datafile ' userdata _01.dbf' size 10M



Example: Using Tablespace

Create table T (a NUMBER)
tablespace tbs_user ;


Bigfile and smallfile tablespace



bigfile tablespace:




Smallfile tablespace (default):

– Constain a single large file
– can be 1024 times larger than a smallfile tablespace

- CREATE BIGFILE TABLESPACE user_tbs

‘oradata/grid/user_tbs01.dbf’ SIZE 1024 M;
can contain up to 1024 files
– DATAFILE

- ALTER TABLESPACE user_tbs RESIZE 10G;


Space Management in Tablespaces




Extent Management
Segment Space Management


Extent Management



Locally managed tablespaces (default)


– uses bitmaps stored in each datafile
– Each bit in the bitmap covers a range of blocks
– Bit value indicates free or used (0-free, 1 used)



Dictionary-managed tablespaces

– Free extents recorded in data dictionary tables (SYS.UET$ and FET$)


Extent Management
Locally Managed Tablespaces
create tablespace large_tabs datafile 'large_tabs_01.dbf' size 10g extent management local uniform size 160m;



Every extent allocated in this tablespace will be 160MB, the bitmap needs only
64 bits

Oracle
will allocate
extents
of 64KB upsize
to 10g
16 extents, from which it will allocate
tablespace
any_tabs datafile
'any_tabs_01.dbf'
• create

progressively larger extents.

extent management local autoallocate;


Segment Space Management





is set per tablespace and applies to all segments in the tablespace
There are two techniques: manual or automatic
There are five bitmaps for each segment: for full blocks used, 75- 100 percent
used; 50 - 75 percent used; 25 - 50 percent used; and 0 - 25 percent used.


Segment Space Management



For instance,

– if the block size is 4KB and the row to be inserted is 1500 bytes
– an appropriate block will be found by searching the 25 percent to 50 percent bitmap.
– Every block on this bitmap is guaranteed to have at least 2KB of free space.


Altering Tablespaces







Taking online and offline
Renaming
Flagging as read-write or read only
Resizing


Taking a Tablespace Online or Offline




An online tablespace or datafile is available for use



cannot take the following tablespaces offline

an offline tablespace or datafile exists as a definition in the data dictionary and
the controlfile but cannot be used

– SYSTEM
– The undo tablespace
– Temporary tablespaces



Taking a Tablespace Online or Offline



ALTER TABLESPACE tablespacename OFFLINE [NORMAL | IMMEDIATE |
TEMPORARY];

– ALTER TABLESPACE users OFFLINE



To bring a tablespace online

– ALTER TABLESPACE users ONLINE;


Mark a Tablespace as Read Only



makes the flights tablespace read-only:

– ALTER TABLESPACE flights READ ONLY;



makes the flights tablespace writable:

– ALTER TABLESPACE flights READ WRITE;



Rename a Tablespace and Its Datafiles



Rename tablespace

– ALTER TABLESPACE users RENAME TO clients;



Rename datafile

– ALTER TABLESPACE users RENAME DATAFILE '/u02/oracle/rbdb1/user1.dbf',
'/u02/oracle/rbdb1/user2.dbf' TO '/u02/oracle/rbdb1/users01.dbf',
'/u02/oracle/rbdb1/users02.dbf';


Resize a Tablespace




Add a data file
Change the size of a data file

– Automatically
– Manually



Add datafile to a tablespace



alter tablespace storedata add datafile ‘STOREDATA_03.DBF' size 50m;


Change size of datafile Manually



alter database datafile '/oradata/users02.dbf' resize 10m;


enable automatic extension of datafile



alter database datafile ‘ \STOREDATA_03.DBF‘ autoextend on next 50m
maxsize 2g;


Dropping Tablespaces





Tablespace removed from data dictionary
Optionally, contents removed from data dictionary

OS files can be deleted with the optional AND DATAFILES clause

– DROP TABLESPACE tbs_02 INCLUDING CONTENTS AND DATAFILES;


×