oracle 简单 doc 命令
连接数库
sqlplus/ as sysdba;
创建用户(创建用户,口令为密码,设置默认表空间是users ,临时表空间是temp)。
create user 用户名
indetified by 密码
default tablespace users
temporary tablespace temp;
授予权限和角色
grant connect to 用户名;
授予用户connect角色,允许用户连接到数据库。
grant resource to 用户名;
授予用户resource角色,允许用户使用数据库中的表空间。
grant select on scott.emp to 用户名;
修改用户的口令
alter user 用户名 identified by 新口令;
修改用户状态
(锁定用户)
alter user 用户名 account lock;
(解锁定用户)
alter user 用户名 account unlock;
修改用户表空间
alter user 用户名 default tablespace users temporary tablespace temp;
删除用户
drop user 用户名 cascade;
授予权限 create session 和角色 dba 给数据库管理员。
grant create session,dba to 用户名;
权限回收
revoke insert on scott.emp from 用户名;
退出
exit;
查看当前登录用户
show user;
切换用户登录
connect 用户名/口令;
创建表空间:
(这里说一哈,在创建表空间的时候要保证存放路径存在,
就是下面例子存放的位置要保证d盘下有一个database文件夹)
create tablespace 表空间名
datafile '存放路径(Eg:[Eg: d:\database\datafiles_1])' size 50M;
创建临时表空间
create temporary tablespace 临时表空间名
tempfile '存放路径(Eg:[Eg: d:\database\usertemp_1.dbf ])' size 50M;
表空间增加10M
alter tablespace 表空间名
add datafile 'filename1' size 50M;
设置表空间为默认的表空间
alter database default tablespace 表空间名;
删除表空间(这里提醒一哈,这里删除仅仅只是删除控制文件中的指针,
并没有删除物理文件,必修在操作系统中物理删除文件)
drop tablespace 表空间名 including contents;