码迷,mamicode.com
首页 > 数据库 > 详细

Oracle自学笔记(一)

时间:2014-05-08 12:18:54      阅读:412      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   ext   

 

1、创建用户并指定表空间

bubuko.com,布布扣
create user gy_3004 identified by gy_3004  
default tablespace gy_3004_data  
temporary tablespace gy_3004_temp;  
bubuko.com,布布扣

2、给用户授予权限

bubuko.com,布布扣
--方式一: 
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 GY_3004;
--方式二: 
grant connect,resource,dba to gy_3004; 
bubuko.com,布布扣

3、创建临时表空间

bubuko.com,布布扣
create temporary tablespace MyTableSpace_temp 
  tempfile D:\Oracle_11g\oradata\orcl\MyTableSpace_temp.dbf 
  size 5M autoextend on 
  next 1M maxsize 5m 
  extent management local;
bubuko.com,布布扣

4、创建数据表空间

bubuko.com,布布扣
create tablespace MyTableSpace_data 
  logging datafile D:\Oracle_11g\oradata\orcl\MyTableSpace_data.dbf 
  size 5m autoextend on
  next 1m maxsize 5m 
  extent management local;
bubuko.com,布布扣

5、查询数据库名

bubuko.com,布布扣
select name from v$database; 
select instance_name from v$instance;
bubuko.com,布布扣

6、查询系统表空间

select tablespace_name from dba_tablespaces;

7、删除用户

drop user gy_3004 cascade;

8、删除表空间

bubuko.com,布布扣
drop tablespace  gy_3004_temp  including contents;
drop tablespace  gy_3004_data  including contents;
bubuko.com,布布扣

9、查看表空间剩余大小 

bubuko.com,布布扣
select tablespace_name,sum(bytes),max(bytes) from dba_free_space group by tablespace_name;
bubuko.com,布布扣

10、查看用户

bubuko.com,布布扣
SELECT * FROM DBA_USERS;
SELECT * FROM ALL_USERS;
SELECT * FROM USER_USERS;
bubuko.com,布布扣

Oracle自学笔记(一),布布扣,bubuko.com

Oracle自学笔记(一)

标签:style   blog   class   code   java   ext   

原文地址:http://www.cnblogs.com/onetwo/p/3714231.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!