一》创建表空间和用户

1.创建临时表空间

create temporary tablespace my_temp(临时表空间名) tempfile '/home/oracle/app/data/my_temp.dbf(自己起个临时表空间名)' size 100m reuse autoextend on next 20m maxsize unlimited;

2.创建表空间

create tablespace newoa(表名) datafile '/home/oracle/app/data/newoa.dbf(表名空间)' size 500M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);

3.创建用户
create user NEWOA(用户名) identified by hs123(密码) default tablespace newoa(表名) temporary tablespace MY_TEMP(临时表空间名);

grant all privileges to 用户名;

grant dba to hc_notify;
grant connect,resource to hc_notify;
grant select any table to hc_notify;
grant delete any table to hc_notify;
grant update any table to hc_notify;
grant insert any table to hc_notify;

二》删除表空间和用户

1.--查看临时表空间文件

select name from v$tempfile;

--查看用户和表空间的关系

select USERNAME,TEMPORARY_TABLESPACE from DBA_USERS;

--如果有用户的默认临时表空间是NOTIFYDB_TEMP的话,建议进行更改

alter user xxx temporary tablespace tempdefault;

---设置tempdefault为默认临时表空间

alter database default temporary tablespace tempdefault;

--删除表空间NOTIFYDB_TEMP及其包含数据对象以及数据文件

drop tablespace NOTIFYDB_TEMP including contents and datafiles;

2.删除用户表空间

-查看表空间文件

select name from v$datafile;

--停止表空间的在线使用

alter tablespace 表空间名称 offline;

--删除表空间NOTIFYDB_TEMP及其包含数据对象以及数据文件

drop tablespace NOTIFYDB_TEMP including contents and datafiles;

3.查看用户权限

--查看所有的用户

select * from all_users;

--查看当前用户信息

select * from user_users;

--查看当前用户的角色

select * from user_role_privs;

--查看当前用户的权限

select * from user_sys_privs;

--查看当前用户的表可操作权限

select * from user_tab_privs;

--查看某一个表的约束,注意表名要 大写

select * from user_constraints where table_name='TBL_XXX';

--查看某一个表的所有索引,注意表名要 大写

select index_name,index_type,status,blevel from user_indexes where table_name = 'TBL_XXX';

--查看索引的构成,注意表名要 大写

select table_name,index_name,column_name, column_position FROM user_ind_columns WHERE table_name='TBL_XXX';

--系统数据字典 DBA_TABLESPACES 中记录了关于表空间的详细信息

select * from sys.dba_tablespaces;

--查看用户序列

select * from user_sequences;

--查看数据库序列

select * from dba_sequences;

 

posted on 2017-02-17 17:57  阡陌客  阅读(369)  评论(0编辑  收藏  举报