zoukankan      html  css  js  c++  java
  • Oracle学习笔记_05_ 一个创建表空间、创建用户、授权的完整过程

    一、完整命令

    su - oracle
    sqlplus /nolog
    conn /as sysdba
    
    create tablespace scaninvoice logging datafile '/u01/app/oracle/oradata/mas/scaninvoice.dbf' size 200M autoextend on next 100m  extent management local;
    create temporary tablespace scaninvoice_tmp tempfile '/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
    
    create user  username  identified by password default tablespace scaninvoice 
    temporary tablespace scaninvoice_tmp;        
    
    grant dba to trainhec ;
    grant dba,create session,resource,connect to trainhec ;
    exit;  

    二、完整过程

    1.以root用户登录linux,然后切换到oracle用户,以sysdba的身份登录oracle

    # su - oracle
    $ sqlplus /nolog
    SQL> conn /as sysdba

    2.创建表空间和临时表空间

    2.1 表空间: 一般在开发情况下,我们当然不会使用用户的默认表空间,所以这时我们需要创建一个表空间. 

    create tablespace scaninvoice logging datafile '/u01/app/oracle/oradata/mas/scaninvoice.dbf' size 200M autoextend on next 100m  extent management local;

    注:datafile后面是表空间的物理存储路径,文件名的后缀可以随便. 若没有dbf文件,则系统会自动创建。

    2.2 临时表空间

    create temporary tablespace scaninvoice_tmp tempfile '/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;

    3.创建用户

    create user  username  identified by password;    //使用默认表空间 USER
    
    create user  username  identified by password default tablespace scaninvoice 
    temporary tablespace scaninvoice_tmp;            //指定默认表空间和临时表空间  (推荐)

    4.授权用户

    grant dba to trainhec ;
    grant dba,create session,resource,connect to trainhec ;
    exit;

    三、附加命令

    1.修改用户密码

    alter user username  identified by password; 

    2.查看所有用户所在的表空间

    默认情况下用户创建好后系统会默认给该用户分配一个表空间(users); 我们可以通过下面的sql语句来查看一下所有用户所在的表空间. 

    select username,default_tablespace from dba_users;  

    3.将表空间分配给用户

    alter user scaninvoice default tablespace scaninvoice;  

    四、参考资料

    1. Oracle创建表空间、创建用户以及授权 

  • 相关阅读:
    最近工作状态异常的原因追寻。
    当“逻辑”与“UE”冲突时
    面对一个“丢失了与用户“签订”的协议的修改”时进行的思考。
    如果公司的需求总是让研发部门有怨言…
    安装sybase12.0,运行时报错异常。
    你看到这份文档,我就想摔鼠标!
    对于研发组长的责任产生了疑惑。
    关于html中空格导致的排版问题
    如何配置你的工作环境。
    今天的笔记:2014年6月3日
  • 原文地址:https://www.cnblogs.com/shirui/p/7879641.html
Copyright © 2011-2022 走看看