Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
18Activity
0 of .
Results for:
No results containing your search query
P. 1
Managing Oracle Tablespaces and datafiles

Managing Oracle Tablespaces and datafiles

Ratings: (0)|Views: 724|Likes:
Published by SHAHID FAROOQ

More info:

Published by: SHAHID FAROOQ on Aug 29, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/25/2012

pdf

text

original

 
Managing Oracle Tablespaces and datafiles
A collection of 19 FAQs on creating and managing tablespaces and data files. Clear answers are provided with tutorial exercises on creating and dropping tablespaces; listingavailable tablespaces; creating and dropping data files; setting tablespaces and data filesoffline; removing corrupted data files. Topics included in this FAQ are:1.What Is an Oracle Tablespace?2.What Is an Oracle Data File?3.How a Tablespace Is Related to Data Files?4.How a Database Is Related to Tablespaces?5.How To View the Tablespaces in the Current Database?6.What Are the Predefined Tablespaces in a Database?7.How To View the Data Files in the Current Database?8.How To Create a new Oracle Data File?9.How To Create a New Tablespace?10.How To Rename a Tablespace?11.How To Drop a Tablespace?12.What Happens to the Data Files If a Tablespace Is Dropped?13.How To Create a Table in a Specific Tablespace?14.How To See Free Space of Each Tablespace?15.How To Bring a Tablespace Offline?16.How To Bring a Tablespace Online?17.How To Add Another Datafile to a Tablespace?18.What Happens If You Lost a Data File?19.How Remove Data Files befor opening a Database?Sample scripts used in this FAQ assumes that you are connected to the server with theSYSTEM user account on the default database instance XE. See other FAQ collectionson how to connect to the server.
What Is an Oracle Tablespace?
An Oracle tablespace is a big unit of logical storage in an Oracle database. It is managedand used by the Oracle server to store structures data objects, like tables and indexes.
What Is an Oracle Data File?
An Oracle data file is a big unit of physical storage in the OS file system. One or manyOracle data files are organized together to provide physical storage to a single Oracletablespace.
How a Tablespace Is Related to Data Files?
Each tablespace in an Oracle database consists of one or more files called datafiles,which are physical structures that conform to the operating system in which Oracle isrunning.
How a Database Is Related to Tablespaces?
 
A database's data is collectively stored in the datafiles that constitute each tablespace of the database. For example, the simplest Oracle database would have one tablespaceand one datafile. Another database can have three tablespaces, each consisting of twodatafiles (for a total of six datafiles).
How To View the Tablespaces in the Current Database?
If you want to get a list of all tablespaces used in the current database instance, you canuse the DBA_TABLESPACES view as shown in the following SQL script example:
SQL> connect SYSTEM/fyicenterConnected.SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS2 FROM USER_TABLESPACES;TABLESPACE_NAME STATUS CONTENTS------------------------------ --------- ---------SYSTEM ONLINE PERMANENTUNDO ONLINE UNDOSYSAUX ONLINE PERMANENTTEMP ONLINE TEMPORARYUSERS ONLINE PERMANENT
What Are the Predefined Tablespaces in a Database?
When you create a new database, Oracle server will create 4 required tablespaces for thenew database:
SYSTEM Tablespace - Every Oracle database contains a tablespace namedSYSTEM, which Oracle creates automatically when the database is created. TheSYSTEM tablespace is always online when the database is open.
SYSAUX Tablespace - The SYSAUX tablespace was installed as an auxiliarytablespace to the SYSTEM tablespace when you created your database. Somedatabase components that formerly created and used separate tablespaces nowoccupy the SYSAUX tablespace.
UNDO Tablespace - UNDO tablespaces are special tablespaces used solely for storing undo information. You cannot create any other segment types (for example,tables or indexes) in undo tablespaces. Each database contains zero or more undotablespaces. In automatic undo management mode, each Oracle instance isassigned one (and only one) undo tablespace. Undo data is managed within an undotablespace using undo segments that are automatically created and maintained byOracle.
TEMP Tablespace - When the SYSTEM tablespace is locally managed, you mustdefine at least one default temporary tablespace when creating a database. A locallymanaged SYSTEM tablespace cannot be used for default temporary storage.
How To View the Data Files in the Current Database?
If you want to get a list of all tablespaces used in the current database instance, you canuse the DBA_TABLESPACES view as shown in the following SQL script example:
SQL> connect SYSTEM/fyicenterConnected.SQL> col tablespace_name format a16;
 
SQL> col file_name format a36;SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES2 FROM DBA_DATA_FILES;TABLESPACE_NAME FILE_NAME BYTES--------------- ------------------------------- ---------USERS \ORACLEXE\ORADATA\XE\USERS.DBF 104857600SYSAUX \ORACLEXE\ORADATA\XE\SYSAUX.DBF 461373440UNDO \ORACLEXE\ORADATA\XE\UNDO.DBF 94371840SYSTEM \ORACLEXE\ORADATA\XE\SYSTEM.DBF 356515840
How To Create a new Oracle Data File?
There is no dedicated statement to create a data file. Data files are created as part of statements that manages other data structures, like tablespace and database.
How To Create a New Tablespace?
If you want a new dataspace, you can use the CREATE TABLESPACE ... DATAFILEstatement as shown in the following script:
SQL> CREATE TABLESPACE my_space2 DATAFILE '/temp/my_space.dbf' SIZE 10M;Tablespace created.SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS2 FROM USER_TABLESPACES;TABLESPACE_NAME STATUS CONTENTS---------------- --------------- ---------SYSTEM ONLINE PERMANENTUNDO ONLINE UNDOSYSAUX ONLINE PERMANENTTEMP ONLINE TEMPORARYUSERS ONLINE PERMANENTMY_SPACE ONLINE PERMANENTSQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES2 FROM DBA_DATA_FILES;TABLESPACE_NAME FILE_NAME BYTES--------------- -------------------------------- ---------USERS \ORACLEXE\ORADATA\XE\USERS.DBF 104857600SYSAUX \ORACLEXE\ORADATA\XE\SYSAUX.DBF 461373440UNDO \ORACLEXE\ORADATA\XE\UNDO.DBF 94371840SYSTEM \ORACLEXE\ORADATA\XE\SYSTEM.DBF 356515840MY_SPACE \TEMP\MY_SPACE.DBF 10485760
So one statement created two structures: a tablespace and a data file. If you check your file system with Windows file explorer, you will see the data file is located in the \tempdirectory of. The data file size is about 10MB. Its contents should be blank and full of \x00at this time.

Activity (18)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
sunny_dba liked this
sunny_dba liked this
brijesh1747 liked this
Prachi Pahtare liked this
acsdba77 liked this
mailmsgill8561 liked this
rosandic liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->