oracle创建数据库及导入导出

 

建立用户:

create user sdps IDENTIFIED by sdps  // 后面是密码
grant create session ,create table,create view to sdps;
grant resource to sdps;

 


一、             逻辑备份:

1) 导出(备份)export

1、 导出当前用户下的表

exp 用户名/密码 tables=(表1,……表n) file=路径+文件名.dmp

如:

exp scott/tiger tables=(emp) file=c:\1.dmp

2、 导出其他用户下的表:(administrator)

exp 管理员/密码 tables(用户.表1,……用户.表n) file=路径+文件名.dmp

如:

exp system/manager tables=(scott.emp) file=c:\1.dmp

3、 导出当前用户的方案:

exp 用户名/密码 file=路径+文件名.dmp

如:

exp scott/tiger file=c:\1.dmp

4、 导出其他用户的方案:(administrator)

exp 管理员/密码 owner=用户名 file=路径+文件名.dmp

如:

exp system/manager owner=scott file=c:\1.dmp


    2) 导入(还原)import

1、 导入表到当前入户下:

imp 用户名/密码 tables=(表1,……表n) file=路径+文件名.dmp

如:

imp scott/tiger tables=(emp) file=c:\1.dmp

2、 导入表到其他用户下:

imp 管理员/密码 touser=用户名 tables=(表1,……表n) file=路径+文件名.dmp

如:

imp system/manager touser=scott tables(emp) file=c:\1.dmp

3、 导入方案到当前用户下:

imp 用户名/密码 file=路径+文件名.dmp

如:

imp scott/tiger file=c:\1.dmp

4、 导入方案到其他用户下:(administrator)

imp 管理员/密码 file=路径+文件名.dmp fromuser=用户1 touser=用户2

如:

imp system/manager file=c:\1.dmp fromuser=scott touser=tiger

二、             表空间的使用:

1、 建立用户表空间:

create tablespace 表空间名 datafile

‘路径+文件1.dbf’ size 大小MB,

‘路径+文件n.dbf’ size 大小MB,

2、 建立临时表空间:

create temporary tablespace 表空间名 temfile

‘路径+文件1.dbf’ size 大小MB,

‘路径+文件n.dbf’ size 大小MB,

建表时没有指定表空间,使用用户的默认表空间。建表时主键和唯一约束会产生索引,没有指定时同样也适用用户默认的空间

建表时不要使用系统表空间,会使Oracle系统性能下降

3、 索引表空间:

命令与建用户表空间相同,以名称区别

              注:Oracle可以将不同对象分别存在不同的表空间中,提高系统性能

4、 建立表时指定表空间:

create table 表名

        字段1 类型 [primary key using index tablespace 索引表空间名]

        ……

        字段n 类型 [约束]

tablespace 用户表空间

5、 建索引命令:

create index 索引名 on 表 (字段) [tablespace 索引表空间名]

注:表空间大小就是表空间中数据文件的大小之和

6、 修改表空间:

1) 修改现有的数据文件/临时文件大小

alter database datafile/tempfile ‘路径+文件名.dbf’ resize 大小MB

2) 给现有的表空间增加数据文件/临时文件

alter tablespace 表空间名 datafile/tempfile ‘路径+文件名.dbf’ size 大小MB

7、 删除表空间:

drop tablespace 表空间名

drop tablespace 表空间名 including contents and datafiles

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值