玩转Oracle(5)

||-------  数据库管理  -------||

//显示初始化参数
show parameter;

//数据库表的逻辑备份与恢复

//导出
1.导出表
exp userid=scott/tiger@ORCL tables=(emp) file=d:/e1.dmp

2.导出其他方案的表,首先要确认自己是sysdba身份
exp userid=system@919959ORCL tables=(scott.emp) file=d:/e1.dmp

3.导出表结构
exp userid=scott/tiger@ORCL tables=(emp) file=d:/e3.dmp rows=n

4.使用直接导出方式(效率比普通导出方式快)
exp userid=scott/tiger@ORCL tables=(emp,dept) file=d:/e4.dmp direct=y

5.导出方案
exp userid=scott/tiger@ORCL owner=scott file=d:/e5.dmp

6.导出数据库,该用户必须是dba
exp userid=system/919959@ORCL full=y inctype=complete file=d:/e6.dmp


//导入
1.导入自己表
imp userid=scott/tiger@ORCL tables=(emp) file=d:/e1.dmp

2.导入表到其他用户
要求该用户具有dba权限,或是imp_full_database
imp userid=system/919959@ORCL tables(emp) file=d:/e2.dmp touser=scott

3.导入表的结构
imp userid=scott/tiger@ORCL tables=(emp) file=d:/e3.dmp rows=n

4.导入数据
imp userid=scott/tiger@ORCL tables=(emp) file=d:/e4.dmp ignore=y


||-------  表空间管理  -------||

建表空间需要dba用户权限

//建立表空间
create tablespace sp001 datafile 'd:/data01.dbf' size 20m uniform size 128k

//使用数据表空间
create table mypart(
deptno number(4),
dname varchar2(14),
loc varchar2(13)
) tablespace sp001;

//使表空间脱机
alter tablespace sp001 offline;

//使表空间联机
alter tablespace sp001 online;

//只读表空间
alter tablespace sp001 read only;

//修改表空间为可读可写
alter tablespace sp001 read write;

//显示表空间包括扩的所有表
select * from all_tables where tablespace_name='sp001';

//知道表明,查看该表属于哪个表空间
select tablespace_name ,table_name from user_tables where table_name='EMP';

//扩展表空间

1.增加数据文件
alter tablespace sp01 add datafile 'd:/sp01.dbf' size 20m;

2.增加数据文件大小(这里需要注意的是数据文件的大小不要超过500m)
alter database datafile 'd:/sp01.dbf' resize 20m;

3.设置文件的自动增长
alter tablespace datafile 'd:/sp01.dbf' autoextend on next 10m maxsize 500m;

//移动数据文件

1.确定数据文件所在表空间
select tablespace_name from dba_data_files where file_name='d:/sp01.dbf';

2.使表空间脱机
alter tablespace sp01 offline;

3.使用命令移动
host move d:/sp01.dbf c:/sp01.dbf;

4.移动数据文件
alter tablespace sp01 rename datafile='d:/sp01.dbf' to 'c:/sp01.dbf'

5.使表空间联机
alter tablespace sp01 online;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值