zoukankan      html  css  js  c++  java
  • oracle创建表空间 授权

    --创建表空间  临时表空间
    create temporary tablespace xiaodai_temp tempfile '/main/app/oracle/oradata/devdb/xiaodai_temp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
    
    create tablespace xiaodai_data logging datafile '/main/app/oracle/oradata/devdb/xiaodai.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
    
    --创建用户/授权
    create user telecom identified by telecom default tablespace xiaodai_data temporary tablespace xiaodai_temp;
    grant create session to telecom;
    grant create table,create view,create trigger, create sequence,create procedure to telecom;
    grant unlimited tablespace to telecom;
    grant connect,resource,dba to telecom;     
    
    
    --删除表空间
    drop tablespace user_temp including contents;
    drop tablespace user_temp including contents and datafiles;

    需要先给oracle设置环境变量,然后去安装目录的bin目录,切换到oracle用户

    执行 ./sqlplus / as sysdba 即可登录

    export ORACLE_HOME=/main/app/oracle/product/11.2.0/db_1
    export ORACLE_SID=xxxx

    其他一些查询表空间等语句:

    -1、查看表空间的名称及大小 
    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; 
    --2、查看表空间物理文件的名称及大小 
    SELECT tablespace_name, 
    file_id, 
    file_name, 
    round(bytes / (1024 * 1024), 0) total_space 
    FROM dba_data_files 
    ORDER BY tablespace_name; 
    --3、查看回滚段名称及大小 
    SELECT segment_name, 
    tablespace_name, 
    r.status, 
    (initial_extent / 1024) initialextent, 
    (next_extent / 1024) nextextent, 
    max_extents, 
    v.curext curextent 
    FROM dba_rollback_segs r, v$rollstat v 
    WHERE r.segment_id = v.usn(+) 
    ORDER BY segment_name; 
    --4、查看控制文件 
    SELECT NAME FROM v$controlfile; 
    --5、查看日志文件 
    SELECT MEMBER FROM v$logfile; 
    --6、查看表空间的使用情况 
    SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name 
    FROM dba_free_space 
    GROUP BY tablespace_name; 
    SELECT a.tablespace_name, 
    a.bytes total, 
    b.bytes used, 
    c.bytes free, 
    (b.bytes * 100) / a.bytes "% USED ", 
    (c.bytes * 100) / a.bytes "% 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、查看数据库库对象 
    SELECT owner, object_type, status, COUNT(*) count# 
    FROM all_objects 
    GROUP BY owner, object_type, status; 
    --8、查看数据库的版本  
    SELECT version 
    FROM product_component_version 
    WHERE substr(product, 1, 6) = 'Oracle'; 
    --9、查看数据库的创建日期和归档方式 
    SELECT created, log_mode, log_mode FROM v$database; 
  • 相关阅读:
    Ubuntu上搭建Watir-Webdriver与Cucumber环境
    使--no-ri --no-rdoc成为gem安装的默认选项
    Ruby require 路径问题
    【原创】LoadRunner Java Vuser脚本的配置和调试指南
    【原创】LoadRunner Java Vuser开发环境配置指南
    【原创】使用Nmon_Analyzer处理较大nmon文件的方法
    2014年,马上要上班啦,希望一切顺利
    关于.jar的文件在cmd中无法连接数据库的问题
    ios 的通知机制
    ios开发小技巧-用宏化简代码
  • 原文地址:https://www.cnblogs.com/radio/p/7359535.html
Copyright © 2011-2022 走看看