SlideShare a Scribd company logo
Tablespaces
Sql>select tablespace_name, file_name from dba_data_files union select tablespace_name, file_name
from dba_temp_files order by 1;

To reduce character of the file_name,define_editor=vi, name permanently and sqlname:

Sql>!

$cd $ORACLE_HOME/sqlplus/admin/

$vi glogin.sql

G (to go to last line)

O (it gives u new line to write)

define_editor=vi

col file_name format a35

col name format a30

set sqlprompt "_USER'@'_CONNECT_IDENTIFIER>"

Tablespace Management Practical’s:--

Views:--

V$sga, v$sgastat, v$sgainfo

V$sysaux_occupants

Desc dba_tablespaces;

Desc dba_data_files;

Desc v$tablespace;

Desc v$datafile;

Desc v$database;

From 8i onwards we can maintain tablespaces locally.

1. To create locally managed tablespace:--

create tablespace tname datafile ‘/path/*.dbf’ size 100M autoextend on;

2. How to add datafile to existing tablespaces?

alter tablespace tname add datafile ‘/path/*.dbf’ size 100M autoextend on;
3.how to drop a tablespace?

Drop tablespace tname including contents and datafiles;

4. How to drop a datafile?

alter tablespace users drop datafile '/data/oracle/dev/data/userdata1.dbf';

To see tablespaces name and datafiles path?

Select tablespace_name, file_name from dba_data_files;

5. How to rename a tablespace?

alter tablespace oldname rename to newname;

6. How to see datafiles sizes?

Select file_name, bytes/1024/1024 “size in MBs” from dba_data_files;

7. How to see creation time of datafiles;

Select name, creation_time from v$datafile;

8.How to resize a datafile?

Alter database datafile ‘/path/*.dbf’ resize 200M;

How to drop tablespace without datafiles?

Drop tablespace tablespacename;

9.How to add orphan datafile to new tablespace?

Create tablespace tname datafile ‘/path/*.dbf’ reuse;

10. How to add one more orphan datafile to existing tablespace?

Alter tablespace tname add datafile ‘/path/*.dbf’ reuse;

11. How to rename the datafile;

Alter tablespace tname offline;

$mv ‘/path/oldname’ ‘/path/newname’

12.We must give information to controlfile.

Alter database rename file ‘/path/dfname.dbf’ to ‘/path/dfname.dbf’;
alter tablespace tname online;

13. How to create big file tablespace?

Create bigfile tablespace big_ts datafile ‘/path/big_ts.dbf’ size 100M autoextend on;



Temporary tablespace practical’s:--

Views:--

Desc dba_temp_files;

Desc v$tempfile;

Desc dba_tablespace_groups;

select * from dba_tablespace_groups;

Select file_name, file_id, status from dba_temp_files;

Select name, file#, creation_time from v$tempfile;

1. how to create temporary tablespace?

Create temporary tablespace tempname tempfile ‘path/temp.dbf’ size 100M autoextend on;

1.1 How to resize the temporary tempfile?

Sql>alter database tempfile ‘/path/temp.dbf’ resize 100M;

2. how to create tablespace group?

select username, temporary_tablespace, default_tablespace

    from dba_users where username = 'TEMPUSER';

Create temporary tablespace temp1 tempfile ‘/path/temp.dbf’ size 100M tablespace group tgrg;

3. how to add existing temp file to group?

Alter tablespace temp2 tablespace group tgrp;

4. how to make temp group as default?

Alter database default temporary tablespace tempgroup;

5. how to drop a tablespace group? First we need to drop members;
alter tablespace temp tablespace group tgrp;

create new temporary tablespace:

create temporary tablespace name tmepfile ‘/path/temp.dbf’ size 100M autoextend on;

make it as default:

alter database default temporary tablespace name

now drop the temporary group members:

drop tablespace tempname including contents and datafiles;




Undo tablespace management:--

Show parameter undo;

Desc v$undostat;

Desc v$rollstat;

We do have only one undo tablespace for one database. When we need more size we will create big one
and replace it.

1. how to create new undo tablespace?

Create undo tablespace undotbs2 datafile ‘/path/undo.dbf’ size 100M;

How to change default undo tablespace?

Alter system set undo_tablespace=’UNDOTBS’ scope=both;

More Related Content

DOCX
Oracle Managed Files
DOCX
Hadoop installation
PDF
Unix Basics Commands
PPTX
R- create a table from a list of files.... before webmining
PPTX
Basic command of hadoop
DOCX
Exadata - BULK DATA LOAD Testing on Database Machine
PDF
HaskellとDebianの辛くて甘い関係
PDF
Unix commands in etl testing
Oracle Managed Files
Hadoop installation
Unix Basics Commands
R- create a table from a list of files.... before webmining
Basic command of hadoop
Exadata - BULK DATA LOAD Testing on Database Machine
HaskellとDebianの辛くて甘い関係
Unix commands in etl testing

What's hot (20)

PDF
Shell实现的windows回收站功能的脚本
PPTX
Hadoop installation on windows
PPTX
Chap 5 php files part-2
PDF
Archlinux install
PPTX
Dc kyiv2010 jun_08
PDF
Codigos
PPTX
5.managing hdfs
PDF
Linux Bash Shell Cheat Sheet for Beginners
PPTX
MongoDB Replication (Dwight Merriman)
PDF
Linux cheat-sheet
PDF
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PDF
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PDF
Unix Command-Line Cheat Sheet BTI2014
PDF
Bash Script Disk Space Utilization Report and EMail
ODT
Huong dan cai dat hadoop
PDF
File Space Usage Information and EMail Report - Shell Script
PPTX
20171014 tips for manipulating filesystem in julia
PPT
Ingest export
PDF
Shell Script to Extract IP Address, MAC Address Information
PPTX
Ch3(working with file)
Shell实现的windows回收站功能的脚本
Hadoop installation on windows
Chap 5 php files part-2
Archlinux install
Dc kyiv2010 jun_08
Codigos
5.managing hdfs
Linux Bash Shell Cheat Sheet for Beginners
MongoDB Replication (Dwight Merriman)
Linux cheat-sheet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Unix Command-Line Cheat Sheet BTI2014
Bash Script Disk Space Utilization Report and EMail
Huong dan cai dat hadoop
File Space Usage Information and EMail Report - Shell Script
20171014 tips for manipulating filesystem in julia
Ingest export
Shell Script to Extract IP Address, MAC Address Information
Ch3(working with file)
Ad

Viewers also liked (8)

PDF
Startupandshutdown
PDF
Introduction to sql server
PDF
Basic commands
DOC
Controlfilemanagement
DOC
Backup&recovery
ODP
Curso basicoseguridadweb slideshare9
PDF
Hype vs. Reality: The AI Explainer
PDF
Study: The Future of VR, AR and Self-Driving Cars
Startupandshutdown
Introduction to sql server
Basic commands
Controlfilemanagement
Backup&recovery
Curso basicoseguridadweb slideshare9
Hype vs. Reality: The AI Explainer
Study: The Future of VR, AR and Self-Driving Cars
Ad

Similar to Tablespaces (20)

PPT
Week 10-11 Managing Tablespaces and Data Files.ppt
PDF
02-Oracle 19c-Storage-Management de Base de Datos
PPTX
Big file tablespaces
PPTX
tablespaces and datafiles in database administration
PPT
Less06 Storage
PPT
Less05 storage
PPT
database-stucture-and-space-managment.ppt
PPT
database-stucture-and-space-managment.ppt
TXT
Oracle11g notes
PDF
Sql for dbaspresentation
PDF
8 i locally_mgr_tbsp
TXT
Scripts related to temp tablespace
PPT
Less07 storage
DOC
Create manula and automaticly database
PPTX
Administration and Management of Users in Oracle / Oracle Database Storage st...
DOC
Oracle dba interview question
PDF
GLOC 2014 NEOOUG - Oracle Database 12c New Features
DOCX
Oracle dba interview questions with answer
Week 10-11 Managing Tablespaces and Data Files.ppt
02-Oracle 19c-Storage-Management de Base de Datos
Big file tablespaces
tablespaces and datafiles in database administration
Less06 Storage
Less05 storage
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Oracle11g notes
Sql for dbaspresentation
8 i locally_mgr_tbsp
Scripts related to temp tablespace
Less07 storage
Create manula and automaticly database
Administration and Management of Users in Oracle / Oracle Database Storage st...
Oracle dba interview question
GLOC 2014 NEOOUG - Oracle Database 12c New Features
Oracle dba interview questions with answer

Tablespaces

  • 2. Sql>select tablespace_name, file_name from dba_data_files union select tablespace_name, file_name from dba_temp_files order by 1; To reduce character of the file_name,define_editor=vi, name permanently and sqlname: Sql>! $cd $ORACLE_HOME/sqlplus/admin/ $vi glogin.sql G (to go to last line) O (it gives u new line to write) define_editor=vi col file_name format a35 col name format a30 set sqlprompt "_USER'@'_CONNECT_IDENTIFIER>" Tablespace Management Practical’s:-- Views:-- V$sga, v$sgastat, v$sgainfo V$sysaux_occupants Desc dba_tablespaces; Desc dba_data_files; Desc v$tablespace; Desc v$datafile; Desc v$database; From 8i onwards we can maintain tablespaces locally. 1. To create locally managed tablespace:-- create tablespace tname datafile ‘/path/*.dbf’ size 100M autoextend on; 2. How to add datafile to existing tablespaces? alter tablespace tname add datafile ‘/path/*.dbf’ size 100M autoextend on;
  • 3. 3.how to drop a tablespace? Drop tablespace tname including contents and datafiles; 4. How to drop a datafile? alter tablespace users drop datafile '/data/oracle/dev/data/userdata1.dbf'; To see tablespaces name and datafiles path? Select tablespace_name, file_name from dba_data_files; 5. How to rename a tablespace? alter tablespace oldname rename to newname; 6. How to see datafiles sizes? Select file_name, bytes/1024/1024 “size in MBs” from dba_data_files; 7. How to see creation time of datafiles; Select name, creation_time from v$datafile; 8.How to resize a datafile? Alter database datafile ‘/path/*.dbf’ resize 200M; How to drop tablespace without datafiles? Drop tablespace tablespacename; 9.How to add orphan datafile to new tablespace? Create tablespace tname datafile ‘/path/*.dbf’ reuse; 10. How to add one more orphan datafile to existing tablespace? Alter tablespace tname add datafile ‘/path/*.dbf’ reuse; 11. How to rename the datafile; Alter tablespace tname offline; $mv ‘/path/oldname’ ‘/path/newname’ 12.We must give information to controlfile. Alter database rename file ‘/path/dfname.dbf’ to ‘/path/dfname.dbf’;
  • 4. alter tablespace tname online; 13. How to create big file tablespace? Create bigfile tablespace big_ts datafile ‘/path/big_ts.dbf’ size 100M autoextend on; Temporary tablespace practical’s:-- Views:-- Desc dba_temp_files; Desc v$tempfile; Desc dba_tablespace_groups; select * from dba_tablespace_groups; Select file_name, file_id, status from dba_temp_files; Select name, file#, creation_time from v$tempfile; 1. how to create temporary tablespace? Create temporary tablespace tempname tempfile ‘path/temp.dbf’ size 100M autoextend on; 1.1 How to resize the temporary tempfile? Sql>alter database tempfile ‘/path/temp.dbf’ resize 100M; 2. how to create tablespace group? select username, temporary_tablespace, default_tablespace from dba_users where username = 'TEMPUSER'; Create temporary tablespace temp1 tempfile ‘/path/temp.dbf’ size 100M tablespace group tgrg; 3. how to add existing temp file to group? Alter tablespace temp2 tablespace group tgrp; 4. how to make temp group as default? Alter database default temporary tablespace tempgroup; 5. how to drop a tablespace group? First we need to drop members;
  • 5. alter tablespace temp tablespace group tgrp; create new temporary tablespace: create temporary tablespace name tmepfile ‘/path/temp.dbf’ size 100M autoextend on; make it as default: alter database default temporary tablespace name now drop the temporary group members: drop tablespace tempname including contents and datafiles; Undo tablespace management:-- Show parameter undo; Desc v$undostat; Desc v$rollstat; We do have only one undo tablespace for one database. When we need more size we will create big one and replace it. 1. how to create new undo tablespace? Create undo tablespace undotbs2 datafile ‘/path/undo.dbf’ size 100M; How to change default undo tablespace? Alter system set undo_tablespace=’UNDOTBS’ scope=both;