zoukankan      html  css  js  c++  java
  • Oracle表空间管理

    1.创建表空间

    create tablespace yyy
    datafile '/u01/oracle/oradata/orcl/yyy01.dbf'
    size 50m
    autoextend on
    next 50m maxsize unlimited
    extent management local

    2. 创建用户

    create user yyy identified by yyy
    default tablespace yyy
    temporary tablespace temp
    profile DEFAULT

    3.用户授权

    -- Grant/Revoke object privileges
    grant select on SYS.V_$SESSION to yyy;
    grant select on SYS.V_$SESSTAT to yyy;
    grant select on SYS.V_$STATNAME to yyy;
    -- Grant/Revoke role privileges
    grant connect to yyy;
    grant resource to yyy;
    -- Grant/Revoke system privileges
    grant create view to yyy;
    grant debug connect session to yyy;
    grant unlimited tablespace to yyy;

    4.查询表空间的大小

    SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
    FROM dba_tablespaces t, dba_data_files d
    WHERE t.tablespace_name = d.tablespace_name
    GROUP BY t.tablespace_name;

    5.查看表空间对应的数据文件id和数据文件名称

    SELECT tablespace_name,
    file_id,
    file_name,
    round(bytes / (1024 * 1024), 0) total_space
    FROM dba_data_files
    ORDER BY tablespace_name;

    6.查看表空间的使用情况

    SELECT a.tablespace_name,
    a.bytes/1024/1024 "total/m",
    b.bytes/1024/1024 "used/m",
    c.bytes/1024/1024 "free/m",
    Round((c.bytes * 100)/a.bytes,2) " FREE %"
    FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
    WHERE a.tablespace_name = b.tablespace_name
    AND a.tablespace_name = c.tablespace_name;

    7.更改表空间大小(dbf)

    alter database datafile '数据文件路径' resize 大小;

    8.删除表空间及关联关系

    DROP TABLESPACE tablesapce_name including contents and datafiles cascade constraint;
  • 相关阅读:
    雷锋依然在人间 工厂方法模式
    为别人做嫁衣 代理模式
    穿什么有这么重要? 装饰模式
    437. Path Sum III
    434. Number of Segments in a String
    447. Add Strings
    414. Third Maximum Number
    412. Fizz Buzz
    404. Sum of Left Leaves
    405. Convert a Number to Hexadecimal
  • 原文地址:https://www.cnblogs.com/cancer-sun/p/5168235.html
Copyright © 2011-2022 走看看