查看数据库的版本信息
/********** 查看数据库的版本信息(管理员命令行) **********/
SQLPLUS /NOLOG
CONNECT / AS SYSDBA
SELECT * FROM V$VERSION;
账户的基本操作
/********** 账户的基本操作(需要有DBA权限) **********/
--(1)查看所有用户的名称、密码、账户状态、表空间、创建时间
SELECT USERNAME,PASSWORD,ACCOUNT_STATUS,DEFAULT_TABLESPACE,CREATED from DBA_USERS;
--(2)查看用户权限
SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE='SCOTT';
SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE='SCOTT';
--(3)SCOTT用户的权限
RESOURCE,CONNECT
--(4)移除权限和授权
REVOKE RESOURCE,CONNECT FROM SCOTT;
GRANT CONNECT,RESOURCE TO SCOTT;
--(5)锁定账户和解锁
ALTER USER SCOTT ACCOUNT LOCK;
ALTER USER SCOTT ACCOUNT UNLOCK;
创建新账户
/********** 创建新账户(需要有DBA权限) **********/
--(1)创建临时表空间
CREATE TEMPORARY TABLESPACE LIUJIAO_TEMP
TEMPFILE 'E:\oracle\product\10.2.0\oradata\orcl\liujiao_temp.dbf'
SIZE 50M
AUTOEXTEND on
NEXT 50M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
--(2)创建数据表空间
CREATE TABLESPACE LIUJIAO_DATA
LOGGING DATAFILE 'E:\oracle\product\10.2.0\oradata\orcl\liujiao_data.dbf'
SIZE 50M
AUTOEXTEND on
NEXT 50M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
--(3)创建用户并指定表空间
CREATE USER LIUJIAO IDENTIFIED BY "LIUJIAO"
DEFAULT TABLESPACE LIUJIAO_DATA
TEMPORARY TABLESPACE LIUJIAO_TEMP;
--(4)给用户授予权限
GRANT CONNECT,RESOURCE TO LIUJIAO;
删除账户
/********** 删除账户(需要有DBA权限) **********/
--(1)删除账户
DROP USER LIUJIAO CASCADE;
--(2)删除表空间
DROP TABLESPACE LIUJIAO_TEMP INCLUDING CONTENTS AND DATAFILES;
DROP TABLESPACE LIUJIAO_DATA INCLUDING CONTENTS AND DATAFILES;
网友评论