Oracle 建立表空间和用户 \ 导出和导入 数据表

Oracle建立表空间和用户                 
[sql] view plain copy
建立表空间和用户的步骤:  
用户  
建立:create user 用户名 identified by "密码";  
授权:grant create session to 用户名;  
            grant create table to  用户名;  
            grant create tablespace to  用户名;  
            grant create view to  用户名;  
grant connect,resource to user;     

[sql] view plain copy
表空间  
建立表空间(一般建N个存数据的表空间和一个索引空间):  
create tablespace 表空间名  
datafile ' 路径(要先建好路径)\***.dbf  ' size *M  
tempfile ' 路径\***.dbf ' size *M  
autoextend on  --自动增长  
--还有一些定义大小的命令,看需要  
 default storage(  
 initial 100K,  
 next 100k,  
);  
[sql] view plain copy
例子:创建表空间  
create tablespace DEMOSPACE   
datafile 'E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf'   
PS:此处需要注意 ,创建表空间需要在oracle 数据库安装目录下D:\oracle\product\11.2.0\dbhome_1 创建,创建在别目录也可以,但是需要对目录设置权限(oracle 11g) 语法自己百度,本人使用这一种。
size 1500M   
autoextend on next 5M maxsize 3000M;   //此处是语句结束
删除表空间  

drop tablespace DEMOSPACE including contents and datafiles  

=============================================================

[sql] view plain copy
例子:创建表空间  
create tablespace DEMOSPACE   
datafile 'E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf'   
size 1500M   
autoextend on next 5M maxsize 3000M;  
删除表空间  
drop tablespace DEMOSPACE including contents and datafiles  

=============================================================

[sql] view plain copy
用户权限  
授予用户使用表空间的权限:  
alter user 用户名 quota unlimited on 表空间;  
或 alter user 用户名 quota *M on 表空间;  

完整例子:
[sql] view plain copy
--表空间  
CREATE TABLESPACE sdt  
DATAFILE 'F:\tablespace\demo' size 800M  
         EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;   
--索引表空间  
CREATE TABLESPACE sdt_Index  
DATAFILE 'F:\tablespace\demo' size 512M           
         EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;       
  
--2.建用户  
create user demo identified by demo   
default tablespace demo;  
   
--3.赋权  
grant connect,resource to demo;  
grant create any sequence to demo;  
grant create any table to demo;  
grant delete any table to demo;  
grant insert any table to demo;  
grant select any table to demo;  
grant unlimited tablespace to demo;  
grant execute any procedure to demo;  
grant update any table to demo;  
grant create any view to demo;  

[sql] view plain copy
--导入导出命令     
ip导出方式: exp demo/demo@127.0.0.1:1521/orcl file=f:/f.dmp full=y  
exp demo/demo@orcl file=f:/f.dmp full=y  

imp demo/demo@orcl file=f:/f.dmp full=y ignore=y  

转自:http://blog.csdn.net/starnight_cbj/article/details/6792364

========================================================

Oracle安装完后,其中有一个缺省的数据库,除了这个缺省的数据库外,我们还可以创建自己的数据库。

    对于初学者来说,为了避免麻烦,可以用'Database Configuration Assistant'向导来创建数据库。

    创建完数据库后,并不能立即在数据库中建表,必须先创建该数据库的用户,并且为该用户指定表空间。

    下面是创建数据库用户的具体过程:

 

    1.假如现在已经建好名为'news'的数据库,此时在F:\oracle\product\10.1.0\oradata\目录下已经存在news目录(注意:我的Oracle10g安装在F:\oracle下,若你的Oracle安装在别的目录,那么你新建的数据库目录就在*\product\10.1.0\oradata\目录下)。

 

    2.在创建用户之前,先要创建表空间:

    其格式为:格式:  create tablespace 表间名 datafile '数据文件名' size 表空间大小;

    如:

    SQL> create tablespace news_tablespace datafile 'D:\oracle\product\10.1.0\oradata\news\news_data.dbf'  size 500M;

    其中'news_tablespace'是你自定义的表空间名称,可以任意取名;'F:\oracle\product\10.1.0\oradata\news\news_data.dbf'是数据文件的 存放位置,'news_data.dbf'文件名也是任意取;'size 500M'是指定该数据文件的大小,也就是表空间的大小。

    3.现在建好了名为'news_tablespace'的表空间,下面就可以创建用户了:

    其格式为:格式:  create user  用户名 identified by 密码  default tablespace 表空间表;

    如:

    SQL> create user news identified by news default tablespace news_tablespace;

    默认表空间'default tablespace'使用上面创建的表空间。

    4.接着授权给新建的用户:

    SQL> grant connect,resource to news;  --表示把 connect,resource权限授予news用户

    SQL> grant dba to news;  --表示把 dba权限授予给news用户

    授权成功。

转自:http://www.cnblogs.com/Percy_Lee/p/5051156.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值