Professional Documents
Culture Documents
Tablespace Management Oracle
Tablespace Management Oracle
change default tablespace to already existing user ---- alter user mahesh
identified by mahesh123 default tablespace mahesh01;
create tablespace with auto extent ---- create tablespace TABLESPACENAME datafile
'/path/DATAFILENAME.dbf' size 2g AUTOEXTEND ON MAXSIZE UNLIMITED;
how to check how many users have same tablespace ---- select
USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users where
DEFAULT_TABLESPACE='MAHESH01';
permissions to write data in tablesapce ---- alter user USERNAME quota unlimited on
TABLESPACENAME;
view all tables in user ---- select * from tab;
view list of datafiles in particular tablespace with size ---- SELECT file_id,
file_name, bytes/1024/1024/1024 size_gb FROM dba_data_files WHERE tablespace_name =
'TABLESPACENAME';
view list of tables in tablespace ---- select table_name from dba_tables where
tablespace_name=’TABLESPACENAME’;
dba_tablespaces;
dba_data_files;
dba_temp_files;
v$tablespace;
v$datafile;
v$log
v$logfile
v$tempfile
v$rollstat
SELECT a.tablespace_name,
ROUND (((c.BYTES - NVL (b.BYTES, 0)) / c.BYTES) * 100,2) percentage_used,
c.BYTES / 1024 / 1024 space_allocated,
ROUND (c.BYTES / 1024 / 1024 - NVL (b.BYTES, 0) / 1024 / 1024,2) space_used,
ROUND (NVL (b.BYTES, 0) / 1024 / 1024, 2) space_free,
c.DATAFILES
FROM dba_tablespaces a,
( SELECT tablespace_name,
SUM (BYTES) BYTES
FROM dba_free_space
GROUP BY tablespace_name
) b,
( SELECT COUNT (1) DATAFILES,
SUM (BYTES) BYTES,
tablespace_name
FROM dba_data_files
GROUP BY tablespace_name
) c
WHERE b.tablespace_name(+) = a.tablespace_name
AND c.tablespace_name(+) = a.tablespace_name
ORDER BY NVL (((c.BYTES - NVL (b.BYTES, 0)) / c.BYTES), 0) DESC;
To get the tablespace for a particular Oracle table ---- select tablespace_name
from all_tables where owner = 'USERNAME' and table_name = 'TABLENAME';
To get the tablespaces for all Oracle tables in a particular library ---- select
table_name, tablespace_name from all_tables where owner = 'USERNAME';
To get the tablespace for a particular Oracle index ---- select tablespace_name
from all_indexes where owner = 'USERNAME' and index_name = 'INDEXNAME';
To get the tablespaces for all Oracle indexes in a particular library ---- select
index_name, tablespace_name from all_indexes where owner = 'USERNAME';
delete row from table ---- delete from tablename where row='row_name';