Oracle用户管理

来源:互联网 发布:京东和淘宝双11销售额 编辑:程序博客网 时间:2024/06/09 22:51
  1. --模式(方案)逻辑概念:一个数据对象的集合,每一个用户  
  2. --都有一个与之同名的模式,用于存放此用户名下的所有数据对象。  
  3. select * from user_objects  
  4. select * from dba_users;  
  5.   
  6. --创建用户  
  7. 1、给用户创建自己的数据表空间  
  8. create tablespace ts  
  9. datafile 'd:\123.dbf'  size 10m  autoextend on;  
  10.   
  11. 2、创建临时表空间  
  12. create temporary tablespace tmp_ts  
  13. tempfile 'd:\tmp123.dbf'  size 5m  autoextend on;  
  14.   
  15. 3、创建用户,并给他指导表空间   
  16. create user zhangsan  
  17. identified by zs123  
  18. default tablespace ts  
  19. temporary tablespace tmp_ts  
  20.   
  21. 4、修改用户密码  
  22. alter user zhangsan identified by zs321;  
  23.   
  24. 5、给用户加锁、解锁  
  25. alter user zhangsan account lock;  
  26. alter user zhangsan account unlock;  
  27.   
  28. --给用户授权  
  29. --权限:--系统权限(create session、访问目录,alter database)      
  30.         --对象权限(对于某张表的insert、update、delete)  
  31.   
  32. 1、直接  
  33. grant create session,alter database to zhangsan;  
  34.   
  35. 2、间接  
  36. 1)创建角色(角色相当于一个权限的集合)  
  37. create role role_zjl;  
  38. 2)给角色授权  
  39. grant create session,alter database,create table to role_zjl;  
  40. 3)把角色授权给用户  
  41. grant role_zjl to zhangsan;  
  42.    
  43.   
  44. --关于表级别的权限  
  45. 直接:  
  46. grant  insert ,update on scott.emp to zhangsan;  
  47. grant all on scott.emp to zhangsan;  
  48. 间接:  
  49. grant all on scott.emp to role_zjl;  
  50. grant role_zjl to zhangsan;  
  51.   
  52.   
  53. --撤销权限  
  54. revoke all on scott.emp from zhangsan;  
  55. revoke role_zjl from zhangsan;  
  56.   
  57. --删除用户  
  58. drop user zhangsan cascade;   
  59.   
  60. --基本的授权 connect  resource  dba 都是系统角色  
  61. --查询当前有哪些角色  
  62. select * from dba_roles;  
  63. --查询指定系统角色拥有哪些权限  
  64. select * from role_sys_privs where  role='DBA'  
  65.   
  66. --------------部署---------------------------------  
  67. grant dba to zhangsan;  
  68.   
  69. --exp/imp传统的数据导入导出工具  
  70. 导出:  
  71. exp scott/tiger@xe file='d:\123.dmp'   
  72. 导入:  
  73. imp scott/tiger@xe file='d:\123.dmp' 
原创粉丝点击