Oracle Study Note : Tablespace and Data Files

1.how to create a tablespace that employs the most common features

1 create tablespace tb_name  #create bigfile tablespace tb_name
2         datafile ‘/u01/dbfile/orcl/tb_name.dbf’
3         size 100m
4         autoextend on maxsize 1000m  #don’t recommend use the AUTOEXTEND feature. if use this feature,suggest always specify a corresponding MAXSIZE.
5 extent management local  #A locally managed tablespace uses a bitmap in the data file to efficiently determine whether an extent is in use
6         uniform size 128k  #instruct Oracle to allocate size for each extent via the UNIFORM SIZE [size] clause.the default uniform extent size is 1MB
7         segment space management auto;  #the SEGMENT SPACE MANAGEMENT AUTO clause instructs Oracle to manage the space within the block.
8         nologging;  #you can turn off the generation of redo for direct path loading.
9         default row store compress advanced;

2.renameing a tablespace. When you rename a tablespace,Oracle updates the name of the tablespace in the data dictionary,control files,and data file headers. Keep in mind that renaming a tablespace doesn’t rename any associated data files.

1 SQL> alter tablespace old_name rename to new_name

3.alter a tablespace logging mode

1 SQL> alter tablespace tb_name nologging;

4.confirm the tablespace logging mode by querying the DBA_TABLESPACES view

1 SQL> select tablespace_name,logging from dba_tablespaces;

5.changing a tablespace’s write mode

1 SQL> alter tablespace tb_name read only; #you can’t make a tablespace that contains active rollback segment read-only.
2 SQL> alter tablespace tb_name read write;
3 SQL> alter table table_name read only; #modify individual tables

6.dropping a tablespace

1 SQL> alter tablespace tb_name offline; #before droping a tablespace,it’s a good practices to first it offline.
2 SQL> drop tablespace tb_name including contents and datafiles cascade constraints;

7.using Oracle Managed Files

a)   DB_CREATE_FILE_DEST

b)   DB_CREATE_ONLINE_LOG_DEST_N

c)   DB_RECOVERY_FILE_DEST

1 SQL> alter system set db_create_file_dest=’/u01’;

8.enabling default table compression within a tablespace

1 SQL> alter tablespace tb_name default row store compress advanced;
2 SQL> alter tablespace tb_name defaule compress [basic | nocompres]

9.displaying oracle error messages and action

1 $ oerr ora 01653

10.altering tablespace size

1 SQL> alter database datafile ‘/u01/user01.dbf’ resize 1g;
2 SQL> alter tablespace users add datafile ‘/u02/users02.dbf’ size 100m;
3 SQL> alter tablespace big_data resize 1T;  #with bigfile tablespace,you have the option of using the ALTER TABLESPACE statement to resize the data file. this works because only one data file can be associated with a bigfile tablespace.

11.to add space to a temporary tablespace

1 SQL> select name,bytes from v$tempfile;  #first query the V$TEMPFILE view to verify the current size and location of temporary data files.
2 SQL> alter database tempfile ‘u01/temp01.dbf’ resize 500m;
3 SQL> alter tablespace temp add tempfile ‘u01/temp02.bdf’ size 5000m;

12.toggling data files offline and online

1 SQL> alter tablespace tb_name offline;
2 SQL> alter database datafile 4 offline for drop  #if your database isn’t in archivelog mode,you must specify ALTER DATAFILE ... OFFLINE FOR DROP when taking a data file offline.When you use the OFFLINE FOR DROP clause, no checkpiont is taken on the data file, this means you need to perform media recovery on the data file before bringing it online.
3 SQL> recovery datafile 4;

13.renaming or relocating a data file.new in Oracle 12c is the ALTER DATABASE MOVE DATAFILE commend.this commend allows you to rename or move datafiles without any downtime.

1 SQL> alter database move datafile ‘u01/user01.dbf’ to ‘/u01/user02.dbf’;
2 SQL> alter database move datafile 4 to ‘u02/user01.dbf’ keep;  #to keep a copy of the original file.
3 SQL> alter database move datafile 4 to ‘/u01/user02.dbf’ reuse;  #specify the REUSE clause to overwrite an existing file.
时间: 2024-10-17 01:03:59

Oracle Study Note : Tablespace and Data Files的相关文章

Oracle Study Note : Users and Basic Security

1. view the default user account 1 SQL> select username from dba_users; 2. lock all users and set their password to expired 1 SQL> select ‘alter user ‘|| username || ‘ password expire account lock;’ from dba_users; 3. A locked user can only be acces

Oracle Study之案例--异构平台传输表空间(Linux至AIX)

Oracle Study之案例--异构平台传输表空间(Linux至AIX) 系统架构: 可                   源    库               目标库 操作系统 Linux RH6    AIX 5.3-09 主机名 rh6(192.168.8.245) aix211(192.168.8.211) 数据版本 Oracle 11gR2 Oracle 11gR2 数据库名 prod orcl 表空间 test1 test1    可传输表空间概述 Oracle 的可传输表空

Oracle Study之--Oracle 单实例11.2.0.1.0升级到11.2.0.3.0

Oracle Study之--Oracle 单实例11.2.0.1.0升级到11.2.0.3.0 系统环境: 操作系统:RedHat EL6(64位) Oracle:    Oracle 11gR2 Oracle 11.2.0.1 单实例升级到11.2.0.3 Oracle 升级的步骤都差不多,先升级Oracle software,然后升级Oracle instance. Oracle 11.2.0.2的patchset No 是:10098816. 关于该Patchset 的下载地址,参考下面

Oracle Study之案例--重建数据库控制文件

Oracle Study之案例--重建数据库控制文件 系统环境: 操作系统: Linux RH6 数据库:   Oracle 11gR2    案例分析:           数据库中所有的控制文件被意外破坏,非归档的库,在有trace备份的情况下,重建控制文件. 1.控制文件trace脚本 [[email protected] ~]$ cat crctr.sql  CREATE CONTROLFILE REUSE DATABASE "TEST3" NORESETLOGS  NOARC

Oracle Study之案例--RMAN备份配置参数

Oracle Study之案例--RMAN备份配置参数 1.PARALLELISM  我们还可以通过parallelism参数来指定同时"自动"创建多少个通道:RMAN > configure device type disk parallelism 3 ; 表示启动三个通道,可以加快备份恢复的速度. 案例分析: RMAN> show all; using target database control file instead of recovery catalog CO

Oracle Study之-Oracle 11g OCM考试(1)

Oracle Study之-Oracle 11g OCM考试(1) 系统环境:RedHat EL64 Oracle:   Oracle 11gR2       Oracle 11g OCM考试第一题,手工建库,参考文档.参考人员必须对文档非常熟悉,才可以在指定的时间内完成任务. 一.查看系统环境 [[email protected] ~]$ cat .bash_profile # .bash_profile export EDITOR=vi export ORACLE_SID=prod expo

Oracle Study之--AIX RAC下OCR磁盘故障(PROT-602)

Oracle Study之--AIX RAC下OCR磁盘故障(PROT-602) ********************************************************************************  Welcome to AIX Version 5.3!                                                **                                                  

Oracle Study之--AIX 6.1安装Oracle 10gR2

Oracle Study之--AIX 6.1安装Oracle 10gR2 1.系统硬件平台 #prtconf |more System Model: IBM,9131-52A   Machine Serial Number: 10367FG   Processor Type: PowerPC_POWER5   Processor Implementation Mode: POWER 5   Processor Version: PV_5_2   Number Of Processors: 2  

Oracle Study之案例--数据恢复神器Flashback(1)

Oracle Study之案例--数据恢复神器Flashback(1) Flashback: Flashback 技术是以Undo segment中的内容为基础的, 因此受限于UNDO_RETENTON参数.要使用flashback 的特性,必须启用自动撤销管理表空间. 在Oracle 11g里又出了一个新特性:Oracle Flashback Data Archive. FDA通过将变化数据另外存储到创建的闪回归档区(Flashback Archive)中,以和undo区别开来,这样就可以为闪