• 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; 
  • 相关阅读:
    在线教育项目-day02【讲师分页功能和多条件组合查询功能】
    在线教育项目-day02【统一结果返回】
    Go语言数组和切片的原理
    Go语言单元测试与基准测试
    PHPWord导出word文档
    Go语言反射reflect
    漫画:什么是HTTPS?
    什么是shell和终端?
    Go接口interface
    Go变量逃逸分析
  • 原文地址:https://www.cnblogs.com/radio/p/7359535.html
Copyright © 2020-2023  润新知