Академический Документы
Профессиональный Документы
Культура Документы
A Tablespaces is a logical unit of Data storage in database, all objects like tables, indexes are
stored into tablespaces. A tablespace is a logical representation of data storage while actual data
is stored into datafiles of the database. A tablespace can have multiple datafile, while a datafile
can be a part of only one tablespace.
Every time when you create a database object like table, index, materialized view etc DBA has to
specify tablespace name in which this object will store, if not given this will go to default
tablespace.
SYSTEM
/opt/oracle/datafile/system.dbf 700
SYSAUX
/opt/oracle/datafile/sysaux.dbf 740
UNDOTBS1
/opt/oracle/datafile/undotbs1.dbf 225
UNDOTBS2
/opt/oracle/datafile/undotbs2.dbf 200
USERS
/opt/oracle/datafile/users.dbf 5
SIZETEST
/opt/oracle/sizetest1.dbf 240
TEST
/opt/oracle/test.dbf 100
7 rows selected.
Here, Tablespace_name shows name of tablespaces in database, File_name is actual file name
at OS Location and Size of file is shown as SIZE_IN_MB. Since, Temp files are not covered in
this view. Command to fine temp tablespace datafile.
SQL> select tablespace_name,file_name,bytes/(1024*1024) size_in_mb from
dba_temp_files;
TABLESPACE_NAME
FILE_NAME SIZE_IN_MB
------------------------------
-------------------------------------------------- ------------
TEMP
/opt/oracle/tempfile/temp.dbf 22
In above query I have making a tablespace with name "lmtbsb" at location "/opt/oracle/" with
data file name "lmtbsb01.dbf" having size 50 MB. After completion of this script DBA can
cross check tablespaces creation using #1 in this post.
When tablespaces is full and doesn't have free space to occupy newly added data, In that case
Database Admin can face "ORA-1653 unable to extend table %s.%s by # in tablespace %s".I
would suggest to use below query to keep an eye on tablespace utilization.
SQL> SELECT b.tablespace_name, b.tablespace_size_mb,
sum(nvl(fs.bytes,0))/1024/1024 free_size_mb,
(sum(nvl(fs.bytes,0))/1024/1024/b.tablespace_size_mb *100) free_percent
FROM dba_free_space fs,
(SELECT tablespace_name, sum(bytes)/1024/1024 tablespace_size_mb FROM
dba_data_files
GROUP BY tablespace_name
) b
where fs.tablespace_name = b.tablespace_name
group by b.tablespace_name, b.tablespace_size_mb;
7 rows selected.
If tablespace is above 90% utilized, I would suggest to increase tablespace size using either
adding datafile to tablespace or resizing existing datafiles.
Resize of datafile. Here I am resizing ASM datafile. Use same command to resize Non ASM
datafile.
SQL> alter database datafile '+DATA/odadata/datafile/users.262.817709621'
resize 10M;
Database altered.
Above command will add 100M of datafile to tablespace lmtb. There are few more options to
solve this issue "ORA-1653 unable to extend table %s.%s by # in tablespace %s"
SQL> !
Relocation of tablespaces datafile has a small change, Instead of renaming datafile we will move
datafile from one place to another place. I am only showing command which is different in
Relocation here.
When tablespaces is in read write mode it will show status as "online", when you change it to
read only this will display status as "READ ONLY" in DBA_TABLESPACES view.
SQL> alter tablespace test read only;
Tablespace altered.
Tablespace altered.
DBA can also drop whole tablespaces with it's datafile using below command.
This is usually done, when you need some free space at OS level, This is a critical activity, so
make sure you don't need data from this tablespace.
Please share your views about this article !!