zoukankan      html  css  js  c++  java
  • Oracle学习笔记(二)

    四、表空间
    分类:
    永久表空间(表,视图,存储过程)
    临时表空间(数据库操作中中间操作过程)
    UNDO表空间 (被修改之前的数据)
    1、查看表空间
    系统管理员查看的表空间
    desc dba_tablesspaces

    select tablespace_name from dba_tablesspaces;

    SYSTEM 存放该用户的表视图,以及存储过程的数据库对象,系统表空间
    SYSAUX 辅助EXAMPLE空间
    UNDOTBSI 撤销信息
    TEMP SQL处理信息和索引的,临时表空间
    USERS 数据库对象创建的数据库表空间,永久的
    EXAMPLE 安装数据库事例的表空间

    普通用户查看的
    desc user_tablespaces

    select tablespace_name from user_tablesspaces;

    dba_users、user_users数据字典
    1、查询默认表空间
    select default_tablespace,temporary_tablespace from dba_users where username='SYSTEM';
    2、设置用户的默认或临时表空间(普通用户没有这个权限)
    alter user system default tablespace system;
    3、创建表空间
    永久
    create tablespace test1_tablespace datafile 'test1file.dbf' size 10m;
    临时
    create temporary tablespace temptest1_tablespace tempfile 'tempfile1.dbf' size 10m;
    查看
    desc dba_data_files

    查找表空间的位置
    select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE';

    查看临时表空间
    select file_name from dba_temp_files where tablespace_name='TEMPTEST1_TABLESPACE';

    4、修改表空间
    (1)设置脱机状态
    alter tablespace test1_tablespace offline;

    查看状态
    desc dba_tablespaces;

    查询
    select status from dba_tablespaces where tablespace_name='TEST1_TABLESPACE';
    (2)设置联机
    alter tablespace test1_tablespace online;

    (3)设置只读(默认可读写)
    alter tablespace test1_tablespace read only;

    (4)设置可读写
    alter tablespace test1_tablespace read write;

    5、修改数据文件

    (1)增加数据文件
    alter tablespace test1_tablespace add datafile 'test2.dbf' size 10m;

    查找表空间的位置
    select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE';

    (2)删除数据文件(不能删除创建表空间的第一个文件)
    alter tablespace test1_tablespace drop datafile 'test2_file.dbf';

    6、删除表空间
    drop tablespace test1_tablespace;
    删除表空间及其中的文件
    drop tablespace test1_tablespace including contents;

  • 相关阅读:
    Eclipse查看源码
    让你的Eclipse的智能感知也和Visual Studio 一样快
    关于The serializable class XXX does not declare a static final serialVersionUID field of type long的警告
    C#中Dictionary的用法及用途实例
    不想人工干预地自动执行存储过程?当目的表发生变动时自动执行相应的存储过程?
    再说HelloWorld
    TreeList应用(三) 收藏
    DataTable转换为List<Model>的通用类
    U盘不显示盘符
    如何在 Eclipse 中显示行号
  • 原文地址:https://www.cnblogs.com/liuyangfirst/p/6416497.html
Copyright © 2011-2022 走看看