表空间命令

# 登陆sqlplus
rsqlplus /nolog
  # 切换到sysdba用户
connect / as SYSDBA
  # 创建表空间了
CREATE SMALLFILE TABLESPACE iptvmdn LOGGING DATAFILE '/opt/oracle/oradb/oradata/inomc/iptvmdn' SIZE 200M AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO ;
  #修改profile
alter profile DEFAULT limit failed_login_attempts unlimited password_life_time unlimited;
  #创建用户
CREATE USER xjdx  IDENTIFIED BY xjdx DEFAULT TABLESPACE  iptvmdn TEMPORARY TABLESPACE TEMP  profile default ACCOUNT UNLOCK;
  #给用户赋权限
GRANT CONNECT TO xjdx;
GRANT DBA TO xjdx;
GRANT CREATE ANY TABLE TO xjdx;
 
# 删除表空间
  DROP TABLESPACE tablespace_name [INCLUDING CONTENTS] [CASCADE CONSTRAINTS]
tablespace_name      --- 表空间名称
INCLUDING CONTENTS   --- 删除表的时候同时删除表中的数据
CASCADE CONSTRAINTS  --- 删除表空间的时候也会删除相关的完整性限制
example:
drop tablespace xjmdn including contents cascade constraints;
  #断开会话
SELECT SID,SERIAL#, status FROM V$SESSION WHERE USERNAME='XJDX';
alter system kill session '70,42550'
 
# 删除用户
DROP USER user CASCADE
  example:
DROP USER xjdx CASCADE

 

 

----创建表空间----
CREATE TABLESPACE UCITDB_data
LOGGING
DATAFILE '/home/app/oracle/app/oracle/oradata/UCITDB/UCITDB_DATA01.DBF'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
----创建表空间----
 
UCITDB_data:用户表空间
 
CREATE USER UCITDBA IDENTIFIED BY 111111
DEFAULT TABLESPACE UCITDB_data;
创建帐号并设置默认表空间
 
UCITDBA:创建的帐号名
111111:为设置帐号的密码
 
grant dba TO UCITDBA
给用户授予权限
dba:用户组
UCITDBA:用户
 
创建临时表空间:
CREATE TEMPORARY TABLESPACE test_temp
TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
 
创建用户表空间:
CREATE TABLESPACE test_data
LOGGING
DATAFILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\TEST_DATA01.DBF'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
 
创建用户并制定表空间:
CREATE USER username IDENTIFIED BY password
DEFAULT TABLESPACE TEST_DATA
TEMPORARY TABLESPACE TEST_TEMP;
 
给用户授予权限:
GRANT
CREATE SESSION, CREATE ANY TABLE, CREATE ANY VIEW ,CREATE ANY INDEX, CREATE ANY PROCEDURE,
ALTER ANY TABLE, ALTER ANY PROCEDURE,
DROP ANY TABLE, DROP ANY VIEW, DROP ANY INDEX, DROP ANY PROCEDURE,
SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE
TO username;
 
将role这个角色授与username,也就是说,使username这个用户可以管理和使用role所拥有的资源
 
GRANT role TO username;
 
-----------------------------------------------查看用户权限---------------------------------------------------------
 
查看所有用户:
SELECT * FROM DBA_USERS;
SELECT * FROM ALL_USERS;
SELECT * FROM USER_USERS;
 
查看用户系统权限:
SELECT * FROM DBA_SYS_PRIVS;
SELECT * FROM USER_SYS_PRIVS;
 
查看用户对象或角色权限:
SELECT * FROM DBA_TAB_PRIVS;
SELECT * FROM ALL_TAB_PRIVS;
SELECT * FROM USER_TAB_PRIVS;
 
查看所有角色:
SELECT * FROM DBA_ROLES;
 
查看用户或角色所拥有的角色:
SELECT * FROM DBA_ROLE_PRIVS;
SELECT * FROM USER_ROLE_PRIVS;
 
------遇到no privileges on tablespace 'tablespace '
alter user userquota 10M[unlimited] on tablespace;

 

 


你可能感兴趣的:(oracle,session,user,table,constraints,logging)