Thursday, November 9, 2017

MANAGING STORAGE STRUCTURE

                                                MANAGING STORAGE STRUCTURE  

TABLESPACE :- ORACLE USE TABLESPACE TO STORE DATA.

TABLESPACE:

Oracle stores Object data logically in tablespaces and physically in datafiles. Oracle databases are logically divided into one or more tablespaces and each Tablespace is made up of one or more physical datafiles. So Oracle use Tablespace to store schema Objects.

WHY TABLESPACE? 

Tablespaces perform a number of key functions in an Oracle database, but the concept of a tablespace is not common to all relational databases. For instance, the Microsoft SQL Server database doesn’t use this concept at all.

Brief list of the benefits of using tablespaces:

• Tablespaces make it easier to allocate space quotas to various users in the database.
• Tablespaces enable you to perform partial backups and recoveries based on the tablespace as a unit.
• Because a large object like a data warehouse partitioned table can be spread over several tablespaces, you can increase performance by spanning the tablespace over several disks and controllers.
• You can take a tablespace offline without having to bring down the entire database.
• Tablespaces are an easy way to allocate database space.

• You can import or export specific application data by using the import and export utilities at the tablespace level.

Firstly we have create table.


SQL> CREATE TABLE T2 TABLESPACE ACC AS SELECT * FROM HR.EMPLOYEES;     

SQL>  SELECT TABLESPACE_NAME FROM USER_TABLES WHERE TABLE_NAME='T2;

TABLESPACE_NAME    
------------------------------                                                  
 ACC  
                                                         
Tablespace Views


SQL> DESC V$TABLESPACE
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 TS#                                                NUMBER
 NAME                                               VARCHAR2(30)
 INCLUDED_IN_DATABASE_BACKUP                        VARCHAR2(3)
 BIGFILE                                            VARCHAR2(3)
 FLASHBACK_ON                                       VARCHAR2(3)
 ENCRYPT_IN_BACKUP                                  VARCHAR2(3)

SQL> SELECT * FROM V$TABLESPACE;

       TS# NAME                           INC BIG FLA ENC                       
---------- ------------------------------ --- --- --- ---                       
         0 SYSTEM                         YES NO  YES                           
         1 SYSAUX                         YES NO  YES                           
         2 UNDOTBS1                       YES NO  YES                           
         4 USERS                          YES NO  YES                           
         3 TEMP                           NO  NO  YES                           
         6 EXAMPLE                        YES NO  YES                           

6 rows selected.

SQL> DESC DBA_DATA_FILES

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 FILE_NAME                                          VARCHAR2(513)
 FILE_ID                                            NUMBER
 TABLESPACE_NAME                                    VARCHAR2(30)
 BYTES                                              NUMBER
 BLOCKS                                             NUMBER
 STATUS                                             VARCHAR2(9)
 RELATIVE_FNO                                       NUMBER
 AUTOEXTENSIBLE                                     VARCHAR2(3)
 MAXBYTES                                           NUMBER
 MAXBLOCKS                                          NUMBER
 INCREMENT_BY                                       NUMBER
 USER_BYTES                                         NUMBER
 USER_BLOCKS                                        NUMBER
 ONLINE_STATUS                                      VARCHAR2(7)

SQL> COL FILE_NAME FOR A45
SQL> COL TABLESPACE_NAME FOR A13
SQL> 
SQL> SELECT TABLESPACE_NAME,FILE_NAME,BYTES/1024/1024 ORG_SIZE_MB,MAXBYTES/1024/1024 MAX_SIZE_MB FROM DBA_DATA_FILES;

TABLESPACE_NA FILE_NAME                                     ORG_SIZE_MB MAX_SIZE_MB                                     
------------- --------------------------------------------- ----------- -----------                                     
USERS         /u01/app/oracle/oradata/orcl/users01.dbf                5  32767.9844                                     
UNDOTBS1      /u01/app/oracle/oradata/orcl/undotbs01.dbf             60  32767.9844                                     
SYSAUX        /u01/app/oracle/oradata/orcl/sysaux01.dbf             510  32767.9844                                     
SYSTEM        /u01/app/oracle/oradata/orcl/system01.dbf             680  32767.9844                                     
EXAMPLE       /u01/app/oracle/oradata/orcl/example01.dbf            100  32767.9844 

No comments:

Post a Comment

How to create user in MY SQL

Create  a new MySQL user Account mysql > CREATE USER ' newuser '@'localhost' IDENTIFIED BY ' password '...