Oracle表空间管理,数据迁移,

本文介绍了数据库管理的各种方法,包括拆迁术、设计术、施工术和迁移术等内容。重点讲解了如何通过设置非标准块的表空间、进行数据字典管理和本地管理等手段来优化数据库。同时,详细阐述了数据库迁移的过程,包括使用数据泵进行导入导出的优点和缺点,以及通过表空间迁移的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

拆迁术:

    赶人:delete

    扒房:truncate

     拆楼:drop

drop table xxx 时如果删除不掉,主要是因为约束,需添加cascade constraints

 analyze table 表名 compute statistics for table

设计术:

         设计大楼外形和空闲空间管理方式extent管理

         设计物业管理segement管理

         设计大小户型---非标准块的表空间

         extend管理(空闲区的管理方式)

         

数据字典管理:select *  from uet$,select * from fet$

本地管理:

               

段空间的管理方式:

           

 

设置非标准块的表空间需要添加blocksize参数,并且分配相应的缓冲区,比如db_4k_cache_size

 

 

施工术:

       拿地:quota

               如果用户只有create table权限,并不能盖楼,还要设置配额:alter user 用户名 10M on users;

               任何表空间无配额限制 分配unlimited tablespace 或connect ,resource角色

       盖楼:create 

       装修:offline和read only

迁移术:

         迁楼:move

             alter table 表名 move tablespace 表空间名称

         迁小区:transport tablespaces

 数据泵导入导出
优点字符集无需设定转换通用
缺点不通用,数据泵导入必须数据泵导出需设定字符集

迁移表空间三步走:

一、创建目录,赋予权限

      cd /home/oracle ;

      mkdir dir;

      grant all on directory dir to public;

二、模拟环境

       create tablespace oltp datafile '/u01/app/oracle/oradata/PROD/disk4/oltp.dbf' size 50M;

       create tablespace olap datafile '/u01/app/oracle/oradata/PROD/disk5/olap.dbf' size 50M;

         create user oltp identified by oracle default tablespace oltp;

         create user olap identified by oracle default tablespace olap;

          grant connect,resource to oltp,olap;

          create table oltp.t_oltp tablespace oltp as select * from scott.emp;

          create table olap.t_olap tablespace olap as select * from scott.emp;

          alter table oltp.t_oltp add constraint pk_oltp primary key(empno);

           alter table olap.t_olap add constraint pk_olap primary key(empno);

           alter table oltp.t_oltp add constraint fk_oltp foreign key(deptno) references scott.dept(deptno);

           alter table olap_olap add constriant fk_olap foreign key(deptno) references scott.dept(deptno);

目标库创建对应用户赋予权限

     create user oltp identified by oracle; grant connect,resource to oltp;

检查自包含:

     execute dbms_tts.transport_set_check('oltp',true)

     select * from transport_set_violations;

      alter table oltp.t_oltp drop constraint fk_oltp cascade;

几字型迁移:

(只读)alter tablespace oltp readonly;

(导出)数据泵:expdp dumpfile=oltp.dmp directory=dir transport_tablespaces=oltp(system用户迁移)

(传输)拷贝: scp 本地目录 远程目录

(导入)拷贝数据文件

impdp dumpfile=oltp.dump directory-dir transport_tablespaces='数据文件所在目录';

(读写)alter tablespace oltp read write;

 

导入导出方式:

设置字符集

        export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

         export ORACLE_SID=xxx

alter tablespace olap read only;

exp file=olap.dmp tablespace=olap transport_tablespace=y

scp 本地目录 远程目录

拷贝数据文件:

imp file=olap.dmp tablespaces=olap transport_tablespace=y datafiles='文件'

alter tablespace olap read write;

转载于:https://www.cnblogs.com/yangyanhao/p/7840493.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值