ºÝºÝߣ

ºÝºÝߣShare 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;
Ad

Recommended

Oracle Managed Files
Oracle Managed Files
Anar Godjaev
?
Hadoop installation
Hadoop installation
habeebulla g
?
Unix Basics Commands
Unix Basics Commands
Sameeran Jenna
?
R- create a table from a list of files.... before webmining
R- create a table from a list of files.... before webmining
Gabriela Plantie
?
Basic command of hadoop
Basic command of hadoop
Ahmad Kabeer
?
Exadata - BULK DATA LOAD Testing on Database Machine
Exadata - BULK DATA LOAD Testing on Database Machine
Monowar Mukul
?
±á²¹²õ°ì±ð±ô±ô¤È¶Ù±ð²ú¾±²¹²Ô¤ÎÐÁ¤¯¤Æ¸Ê¤¤év‚S
±á²¹²õ°ì±ð±ô±ô¤È¶Ù±ð²ú¾±²¹²Ô¤ÎÐÁ¤¯¤Æ¸Ê¤¤év‚S
Kiwamu Okabe
?
Unix commands in etl testing
Unix commands in etl testing
Garuda Trainings
?
³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
Lingfei Kong
?
Hadoop installation on windows
Hadoop installation on windows
habeebulla g
?
Chap 5 php files part-2
Chap 5 php files part-2
monikadeshmane
?
Archlinux install
Archlinux install
sambismo
?
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
Andrii Podanenko
?
Codigos
Codigos
Brian Joseff
?
5.managing hdfs
5.managing hdfs
databloginfo
?
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
?
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
MongoSF
?
Linux cheat-sheet
Linux cheat-sheet
Craig Cannon
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
?
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
No¨¦ Fern¨¢ndez-Pozo
?
Bash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMail
VCP Muthukrishna
?
Huong dan cai dat hadoop
Huong dan cai dat hadoop
Qu?nh Phan
?
File Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell Script
VCP Muthukrishna
?
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
ÔÀÈA ¶Å
?
Ingest export
Ingest export
Digna De Los Santos
?
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address Information
VCP Muthukrishna
?
Ch3(working with file)
Ch3(working with file)
Chhom Karath
?
Startupandshutdown
Startupandshutdown
Vinay Thota
?
Introduction to sql server
Introduction to sql server
Vinay Thota
?

More Related Content

What's hot (20)

³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
Lingfei Kong
?
Hadoop installation on windows
Hadoop installation on windows
habeebulla g
?
Chap 5 php files part-2
Chap 5 php files part-2
monikadeshmane
?
Archlinux install
Archlinux install
sambismo
?
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
Andrii Podanenko
?
Codigos
Codigos
Brian Joseff
?
5.managing hdfs
5.managing hdfs
databloginfo
?
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
?
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
MongoSF
?
Linux cheat-sheet
Linux cheat-sheet
Craig Cannon
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
?
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
No¨¦ Fern¨¢ndez-Pozo
?
Bash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMail
VCP Muthukrishna
?
Huong dan cai dat hadoop
Huong dan cai dat hadoop
Qu?nh Phan
?
File Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell Script
VCP Muthukrishna
?
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
ÔÀÈA ¶Å
?
Ingest export
Ingest export
Digna De Los Santos
?
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address Information
VCP Muthukrishna
?
Ch3(working with file)
Ch3(working with file)
Chhom Karath
?
³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
³§³ó±ð±ô±ôʵÏֵķɾ±²Ô»å´Ç·É²õ»ØÊÕÕ¾¹¦ÄܵĽű¾
Lingfei Kong
?
Hadoop installation on windows
Hadoop installation on windows
habeebulla g
?
Archlinux install
Archlinux install
sambismo
?
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
?
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
MongoSF
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
?
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
?
Bash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMail
VCP Muthukrishna
?
Huong dan cai dat hadoop
Huong dan cai dat hadoop
Qu?nh Phan
?
File Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell Script
VCP Muthukrishna
?
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
ÔÀÈA ¶Å
?
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address Information
VCP Muthukrishna
?
Ch3(working with file)
Ch3(working with file)
Chhom Karath
?

Viewers also liked (8)

Startupandshutdown
Startupandshutdown
Vinay Thota
?
Introduction to sql server
Introduction to sql server
Vinay Thota
?
Basic commands
Basic commands
Vinay Thota
?
Controlfilemanagement
Controlfilemanagement
Vinay Thota
?
Backup&recovery
Backup&recovery
Vinay Thota
?
Curso basicoseguridadweb slideshare9
tantascosasquenose
?
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
?
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
?
Introduction to sql server
Introduction to sql server
Vinay Thota
?
Controlfilemanagement
Controlfilemanagement
Vinay Thota
?
Curso basicoseguridadweb slideshare9
tantascosasquenose
?
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
?
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
?
Ad

Similar to Tablespaces (20)

Week 10-11 Managing Tablespaces and Data Files.ppt
Week 10-11 Managing Tablespaces and Data Files.ppt
IqraHanif27
?
02-Oracle 19c-Storage-Management de Base de Datos
02-Oracle 19c-Storage-Management de Base de Datos
FreddyRonaldSandoval
?
Big file tablespaces
Big file tablespaces
dev3993
?
tablespaces and datafiles in database administration
tablespaces and datafiles in database administration
AsharJaved14
?
Less06 Storage
Less06 Storage
vivaankumar
?
Less05 storage
Less05 storage
Imran Ali
?
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Iftikhar70
?
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
subbu998029
?
Oracle11g notes
Oracle11g notes
Manish Mudhliyar
?
Sql for dbaspresentation
Sql for dbaspresentation
oracle documents
?
8 i locally_mgr_tbsp
8 i locally_mgr_tbsp
Anil Pandey
?
Scripts related to temp tablespace
Scripts related to temp tablespace
Soumya Das
?
Less07 storage
Less07 storage
Amit Bhalla
?
Create manula and automaticly database
Create manula and automaticly database
Anar Godjaev
?
Administration and Management of Users in Oracle / Oracle Database Storage st...
Administration and Management of Users in Oracle / Oracle Database Storage st...
rajeshkumarcse2001
?
ADBMS Unit-II c
ADBMS Unit-II c
SSN College of Engineering, Kalavakkam
?
Oracle dba interview question
Oracle dba interview question
Amarendra Sharma
?
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New Features
Biju Thomas
?
Oracle dba interview questions with answer
Oracle dba interview questions with answer
upenpriti
?
21
21
hanumanthareddy
?
Week 10-11 Managing Tablespaces and Data Files.ppt
Week 10-11 Managing Tablespaces and Data Files.ppt
IqraHanif27
?
02-Oracle 19c-Storage-Management de Base de Datos
02-Oracle 19c-Storage-Management de Base de Datos
FreddyRonaldSandoval
?
Big file tablespaces
Big file tablespaces
dev3993
?
tablespaces and datafiles in database administration
tablespaces and datafiles in database administration
AsharJaved14
?
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Iftikhar70
?
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
subbu998029
?
8 i locally_mgr_tbsp
8 i locally_mgr_tbsp
Anil Pandey
?
Scripts related to temp tablespace
Scripts related to temp tablespace
Soumya Das
?
Create manula and automaticly database
Create manula and automaticly database
Anar Godjaev
?
Administration and Management of Users in Oracle / Oracle Database Storage st...
Administration and Management of Users in Oracle / Oracle Database Storage st...
rajeshkumarcse2001
?
Oracle dba interview question
Oracle dba interview question
Amarendra Sharma
?
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New Features
Biju Thomas
?
Oracle dba interview questions with answer
Oracle dba interview questions with answer
upenpriti
?
Ad

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;