自己的oracle笔记,以后学到的新知识就在这个帖子跟新。
drop user ewedu cascade;--删除和ewedu相关联的所有数据
创建临时表空间
CREATE TEMPORARY TABLESPACE EWEDU_TEMP
TEMPFILE 'E:\\bw\\EWEDU_TEMP.dbf'
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL; 创建用户表空间
创建用户表空间
CREATE TABLESPACE EWEDU_DATA
LOGGING
DATAFILE ' E:\\bw\\EWEDU_DATA.DBF '
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL; 创建用户并制定表空间
imp system/hack520 file=E:\\八维\\bawei.dmp fromuser=ewedu touser=ewedu
先必须查询表空间,数据库所在表空间
select tablespace_name from user_tablespaces;
知道表空间名,显示该表空间包括的所有表。
select * from all_tables where tablespace_name='表空间名'知道表名,
查看该表属于那个表空间
select tablespace_name,table_name from user_tables where table_name='emp'
select * from user_tables where table_name='BW_XY_CLASSCOMMITTEE'
-- 连接本地实例
--conn /@orcl as sysdba;
conn sys/hack520 as sysdba;
-- 删除用户 "oauser"
drop user oauser cascade;
-- 删除表空间 "oauser"
drop TEMPORARY TABLESPACE bwie_temp;
drop tablespace beie_TEMP;
commit;
--drop table SYS_CONDES
CREATE USER EWEDU IDENTIFIED BY EWEDU_DATA
DEFAULT TABLESPACE EWEDU_DATA
TEMPORARY TABLESPACE EWEDU_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 dba to username;赋值所有权限给用户username
GRANT role TO username;
-----------------------------------------------
查看用户权限
select * from role_sys_privs where role='RESOURCE';
查看所有用户
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;
-- 连接本地实例
conn sys/hack520 as sysdba;
-- 创建表空间 “DATA”
CREATE TABLESPACE NEWER_DATA DATAFILE 'G:\\NEWER_DATA.DBF' SIZE 100M reuse AUTOEXTEND ON
NEXT 5M MAXSIZE UNLIMITED;
-- 创建表空间 “TEMP”
CREATE TEMPORARY TABLESPACE NEWER_TEMP TEMPFILE 'G:\\NEWER_TEMP.DBF' SIZE 100M reuse
AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED;
-- 创建用户 “TEMP"
CREATE USER NEWER PROFILE DEFAULT IDENTIFIED BY NEWER DEFAULT TABLESPACE NEWER_DATA
TEMPORARY TABLESPACE NEWER_TEMP ACCOUNT UNLOCK;
-- 对用户 "newer" 授权
GRANT DBA TO NEWER;
commit;
exit;