zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    软件部门每年耗资大约100亿到200多亿美元,但没有研发出任何具有说服力的产品,因此华为决定关闭
    Qt Model/View理解(二)---构造model(细心研读,发现超简单,Model就是做三件事:返回行数量、列数量、data如何显示。然后把model与view联系起来即可,两个例子都是如此)good
    linux 下用find命令查找文件,rm命令删除文件
    北电之死:谁谋杀了华为的对手?——银湖资本(Silver Lake)董事总经理爱德华·詹德出任CEO,既不了解华为,也不重视中国,直截了当地否决了收购华为
    搞定JavaScript正则表达式
    Orleans3.0
    CSS盒模型
    作用域和闭包
    NServiceBus是.Net平台下的开源的消息服务框架
    [1]System.Reflection.Emit
  • 原文地址:https://www.cnblogs.com/zhnhelloworld/p/4285418.html
Copyright © 2011-2022 走看看