SlideShare une entreprise Scribd logo
1  sur  5
Télécharger pour lire hors ligne
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;

Contenu connexe

Tendances

Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Lingfei Kong
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows habeebulla g
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2monikadeshmane
 
Archlinux install
Archlinux installArchlinux install
Archlinux installsambismo
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersDavide Ciambelli
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)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 PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetWalter Heck
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with PuppetOlinData
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Bash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMailBash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMailVCP Muthukrishna
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoopQuỳnh Phan
 
File Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell ScriptFile Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell ScriptVCP Muthukrishna
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia岳華 杜
 
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationShell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationVCP Muthukrishna
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)Chhom Karath
 

Tendances (20)

Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Hadoop installation on windows
Hadoop installation on windows Hadoop installation on windows
Hadoop installation on windows
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2
 
Archlinux install
Archlinux installArchlinux install
Archlinux install
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
 
Codigos
CodigosCodigos
Codigos
 
5.managing hdfs
5.managing hdfs5.managing hdfs
5.managing hdfs
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp 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
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Bash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMailBash Script Disk Space Utilization Report and EMail
Bash Script Disk Space Utilization Report and EMail
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
 
File Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell ScriptFile Space Usage Information and EMail Report - Shell Script
File Space Usage Information and EMail Report - Shell Script
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
 
Ingest export
Ingest exportIngest export
Ingest export
 
Shell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address InformationShell Script to Extract IP Address, MAC Address Information
Shell Script to Extract IP Address, MAC Address Information
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)
 

En vedette

Startupandshutdown
StartupandshutdownStartupandshutdown
StartupandshutdownVinay Thota
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql serverVinay Thota
 
Controlfilemanagement
ControlfilemanagementControlfilemanagement
ControlfilemanagementVinay Thota
 
Curso basicoseguridadweb slideshare9
Curso basicoseguridadweb slideshare9Curso basicoseguridadweb slideshare9
Curso basicoseguridadweb slideshare9tantascosasquenose
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

En vedette (8)

Startupandshutdown
StartupandshutdownStartupandshutdown
Startupandshutdown
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
 
Basic commands
Basic commandsBasic commands
Basic commands
 
Controlfilemanagement
ControlfilemanagementControlfilemanagement
Controlfilemanagement
 
Backup&recovery
Backup&recoveryBackup&recovery
Backup&recovery
 
Curso basicoseguridadweb slideshare9
Curso basicoseguridadweb slideshare9Curso basicoseguridadweb slideshare9
Curso basicoseguridadweb slideshare9
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similaire à Tablespaces

Scripts related to temp tablespace
Scripts related to temp tablespaceScripts related to temp tablespace
Scripts related to temp tablespaceSoumya Das
 
Rman cloning guide
Rman cloning guideRman cloning guide
Rman cloning guideAmit87_dba
 
Drupal Deployment Troubles and Problems
Drupal Deployment Troubles and ProblemsDrupal Deployment Troubles and Problems
Drupal Deployment Troubles and ProblemsAndrii Lundiak
 
Create manula and automaticly database
Create manula and automaticly databaseCreate manula and automaticly database
Create manula and automaticly databaseAnar Godjaev
 
Cloning Oracle EBS R12: A Step by Step Procedure
Cloning Oracle EBS R12: A Step by Step ProcedureCloning Oracle EBS R12: A Step by Step Procedure
Cloning Oracle EBS R12: A Step by Step ProcedureOrazer Technologies
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualKuntal Bhowmick
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and RecoveryAnar Godjaev
 
How to create a non managed standby database
How to create a non managed  standby databaseHow to create a non managed  standby database
How to create a non managed standby databaseJorge Batista
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Unix primer
Unix primerUnix primer
Unix primerdummy
 
Database administration commands
Database administration commands Database administration commands
Database administration commands Varsha Ajith
 
2011 384 hackworth_ppt
2011 384 hackworth_ppt2011 384 hackworth_ppt
2011 384 hackworth_pptmaclean liu
 
Oracle exports and imports windows 7
Oracle exports and imports windows 7Oracle exports and imports windows 7
Oracle exports and imports windows 7selvammstr
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overviewAmeer Sameer
 
br_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.docbr_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.docLucky Ally
 
Oracle data guard configuration in 12c
Oracle data guard configuration in 12cOracle data guard configuration in 12c
Oracle data guard configuration in 12cuzzal basak
 
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesEfficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesSeth Miller
 

Similaire à Tablespaces (20)

Scripts related to temp tablespace
Scripts related to temp tablespaceScripts related to temp tablespace
Scripts related to temp tablespace
 
Rman cloning guide
Rman cloning guideRman cloning guide
Rman cloning guide
 
Drupal Deployment Troubles and Problems
Drupal Deployment Troubles and ProblemsDrupal Deployment Troubles and Problems
Drupal Deployment Troubles and Problems
 
Create manula and automaticly database
Create manula and automaticly databaseCreate manula and automaticly database
Create manula and automaticly database
 
Cloning Oracle EBS R12: A Step by Step Procedure
Cloning Oracle EBS R12: A Step by Step ProcedureCloning Oracle EBS R12: A Step by Step Procedure
Cloning Oracle EBS R12: A Step by Step Procedure
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and Recovery
 
How to create a non managed standby database
How to create a non managed  standby databaseHow to create a non managed  standby database
How to create a non managed standby database
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Unix primer
Unix primerUnix primer
Unix primer
 
Database administration commands
Database administration commands Database administration commands
Database administration commands
 
2011 384 hackworth_ppt
2011 384 hackworth_ppt2011 384 hackworth_ppt
2011 384 hackworth_ppt
 
Oracle exports and imports windows 7
Oracle exports and imports windows 7Oracle exports and imports windows 7
Oracle exports and imports windows 7
 
Cria db.sql
Cria db.sqlCria db.sql
Cria db.sql
 
Common linux ubuntu commands overview
Common linux  ubuntu commands overviewCommon linux  ubuntu commands overview
Common linux ubuntu commands overview
 
br_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.docbr_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.doc
 
Dbmail
DbmailDbmail
Dbmail
 
Oracle data guard configuration in 12c
Oracle data guard configuration in 12cOracle data guard configuration in 12c
Oracle data guard configuration in 12c
 
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesEfficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
 

Tablespaces

  • 1.
  • 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;