Wednesday, 11 December 2013

How to create tablespaces in oracle


SQL*Plus: Release 9.2.0.1.0 - Production on Sun Jan 25 08:02:49 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL> conn /as sysdba;
Connected.
SQL> create tablespace tinku datafile 'e:\oracle\oradata\iacm\tinku01.dbf' size
5m;

Tablespace created.

SQL>


SQL> create tablespace raj datafile 'e:\oracle\oradata\iacm\raj01.dbf' size 5m
extent management local uniform size 128k;

Tablespace created.

SQL>

SQL> create undo tablespace undotbs2 datafile 'e:\oracle\oradata\iacm\undotbs02.
dbf' size 10m;

Tablespace created.

SQL> create temporary tablespace temp1 tempfile 'e:\oracle\oradata\iacm\temo01.d
bf' size 10m ;

Tablespace created.

SQL>

SQL> alter database default temporary tablespace temp1;

Database altered.

SQL> alter tablespace tinku read only;

Tablespace altered.

SQL> alter tablespace tinku read write;

Tablespace altered.

SQL> alter tablespace tinku offline;

Tablespace altered.

SQL> alter tablespace tinku online;

Tablespace altered.

SQL> select * from v$tablespace;

       TS# NAME                           INC
---------- ------------------------------ ---
         3 CWMLITE                        YES
         4 DRSYS                          YES
         5 EXAMPLE                        YES
         6 INDX                           YES
         7 ODM                            YES
         0 SYSTEM                         YES
         8 TOOLS                          YES
         1 UNDOTBS1                       YES
         9 USERS                          YES
        10 XDB                            YES
         2 TEMP                           YES

       TS# NAME                           INC
---------- ------------------------------ ---
        12 TINKU                          YES
        13 RAJ                            YES
        11 UNDOTBS2                       YES
        14 TEMP1                          YES

15 rows selected.


SQL> column tablespace_name format a30;
SQL> column file_name format a30;


SQL> select file_name,tablespace_name,status from dba_data_files;

FILE_NAME                      TABLESPACE_NAME                STATUS
------------------------------ ------------------------------ ---------
E:\ORACLE\ORADATA\IACM\SYSTEM0 SYSTEM                         AVAILABLE
1.DBF

E:\ORACLE\ORADATA\IACM\UNDOTBS UNDOTBS1                       AVAILABLE
01.DBF

E:\ORACLE\ORADATA\IACM\CWMLITE CWMLITE                        AVAILABLE
01.DBF

E:\ORACLE\ORADATA\IACM\DRSYS01 DRSYS                          AVAILABLE
.DBF

FILE_NAME                      TABLESPACE_NAME                STATUS
------------------------------ ------------------------------ ---------

E:\ORACLE\ORADATA\IACM\EXAMPLE EXAMPLE                        AVAILABLE
01.DBF

E:\ORACLE\ORADATA\IACM\INDX01. INDX                           AVAILABLE
DBF

E:\ORACLE\ORADATA\IACM\ODM01.D ODM                            AVAILABLE
BF

E:\ORACLE\ORADATA\IACM\TOOLS01 TOOLS                          AVAILABLE

FILE_NAME                      TABLESPACE_NAME                STATUS
------------------------------ ------------------------------ ---------
.DBF

E:\ORACLE\ORADATA\IACM\USERS01 USERS                          AVAILABLE
.DBF

E:\ORACLE\ORADATA\IACM\XDB01.D XDB                            AVAILABLE
BF

E:\ORACLE\ORADATA\IACM\TINKU01 TINKU                          AVAILABLE
.DBF


FILE_NAME                      TABLESPACE_NAME                STATUS
------------------------------ ------------------------------ ---------
E:\ORACLE\ORADATA\IACM\RAJ01.D RAJ                            AVAILABLE
BF

E:\ORACLE\ORADATA\IACM\UNDOTBS UNDOTBS2                       AVAILABLE
02.DBF


13 rows selected.


SQL> alter database datafile 'e:\oracle\oradata\iacm\raj01.dbf' resize 20m;

Database altered.

SQL> alter tablespace tinku add datafile 'e:\oracle\oradata\iacm\ti01.dbf' size
10m;

Tablespace altered.


SQL> drop tablespace raj including contents and datafiles;

Tablespace dropped.

SQL>

No comments:

Post a Comment