oracle 表迁移方法 (一)
在生产系统中,因业务需求,56张表中清空54张表数据,另外两张表数据保留,数据量大约10G左右:
1.大部分人想法就是expdp/impdp,的确是这样,哈哈
2.rman
3.以下方法,move
虚拟机单表模拟如下:
[oracle@db01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Nov 3 18:40:16 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
创建表空间
SQL> create tablespace dahao datafile '/u01/app/oracle/oradata/orcl/dahao01.dbf' size 100m;
Tablespace created.
创建用户
SQL> create user dahao identified by dahao default tablespace dahao;
User created.
授权
SQL> grant dba to dahao;
Grant succeeded.
SQL> conn dahao/dahao
Connected.
SQL> show user
USER is "DAHAO"
创建测试表
SQL> create table dahao as select * from scott.emp;
Table created.
查看索引
SQL> select index_name from user_indexes;
no rows selected
创建索引
SQL> create index index_empno on dahao(empno) tablespace users;
Index created.
查看索引
SQL> select index_name from user_indexes;
INDEX_NAME
------------------------------
INDEX_EMPNO
创建表move的表空间
SQL> create tablespace yoon datafile '/u01/app/oracle/oradata/orcl/yoon01.dbf' size 100m;
Tablespace created.
将表设置只读模式
SQL> alter table dahao.dahao read only;
Table altered.
迁移表对应表空间
SQL> alter table dahao.dahao move tablespace yoon;
Table altered.
修改用户默认表空间
SQL> alter user dahao identified by dahao default tablespace yoon;
User altered.
查看表状态
SQL> select TABLE_NAME,TABLESPACE_NAME,READ_ONLY from dba_tables where owner='DAHAO' and table_name='DAHAO';
TABLE_NAME TABLESPACE_NAME REA
------------------------------ ------------------------------ ---
DAHAO YOON YES
SQL> show user
USER is "DAHAO"
SQL> select index_name from user_indexes;
INDEX_NAME
------------------------------
INDEX_EMPNO
查看索引状态,失效
SQL> select INDEX_NAME,TABLE_OWNER,TABLE_NAME,STATUS from user_indexes where index_name='INDEX_EMPNO';
INDEX_NAME TABLE_OWNER TABLE_NAME STATUS
------------------------------ ------------------------------ ------------------------------ --------
INDEX_EMPNO DAHAO DAHAO UNUSABLE
重建索引
SQL> alter index index_empno rebuild tablespace users;
Index altered.
查看用户默认表空间
SQL> select username,default_tablespace from dba_users;
DAHAO YOON
将表设置读写模式
SQL> alter table dahao read write;
Table altered.
查看表状态
SQL> select TABLE_NAME,TABLESPACE_NAME,READ_ONLY from dba_tables where owner='DAHAO' and table_name='DAHAO';
TABLE_NAME TABLESPACE_NAME REA
------------------------------ ------------------------------ ---
DAHAO YOON NO
oracle 表迁移方法 (一)的更多相关文章
- oracle 表迁移方法 (二) 约束不失效
DB:11.2.0.3.0 在oracle 表迁移方法 (一)中,只是move了一张普通的表,如果表的字段带有主键约束呢 ? [oracle@db01 ~]$ sqlplus / as sysdba ...
- Oracle表空间数据文件移动的方法
最近遇到这样的一个问题,Oracle存放表空间文件的盘符 空间不够了,必须把部分表空间迁移出去, [转]http://www.jb51.net/article/77026.htm 实现把用户表空间中的 ...
- oracle 表空间和表 read only迁移后不再read only
DB : 11.2.0.3.0 1.将tablespace read only , 不允许再对表进行update.insert操作,测试dmp到另一个用户.表空间后是否可以update.insert ...
- 将Oracle表导入到Access方法,已经安装了Access但Win7提示 找不到access driver
已经安装了Access但Win7提示 找不到access driver: 1.打开 "C:\Windows\SysWOW64\odbcad32.exe" 2.管理员cmd运行 命令 ...
- oracle表空间表分区详解及oracle表分区查询使用方法(转+整理)
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- Oracle 11gR2 用exp无法导出空表解决方法
Oracle 11gR2 用exp无法导出空表解决方法 在11gR2中有个新特性,当表无数据时,不分配segment以节省空间.Oracle 当然在运行export导出时,空表则无法导出,可是还是有解 ...
- ORACLE表数据误删除的恢复方法(提交事务也可以)
ORACLE表数据误删除的恢复方法(提交事务也可以) 缓存加时间戳 开启行移动功能:ALTER TABLE tablename ENABLE row movement 把表还原到指定时间点:flash ...
- Oracle表空间迁移Move Tablespace
move一个表到另外一个表空间时,索引不会跟着一起move,而且会失效.(LOB类型例外) move分为: *普通表move *分区表move *LONG,LOB大字段类型move来进行测试和说明. ...
- ORACLE 表空间扩展方法
ORACLE 表空间扩展方法 环境: linux系统 工具:PL/SQL DEVELOPER 第一步:查看表空间的名字及文件所在位置: select tablespace_name, file_id, ...
随机推荐
- 使用Flex4的PopUpManager的addPopUp() 方法弹出 removeChild异常的解决办法
Flex4中,弹出窗口有两种: Alert.show("balabalabala-"); PopUpManager.addPopUp([要弹出的控件],[父控件],[是否模态] ...
- socket学习笔记——线程(聊天程序)
server.c #include <stdio.h> #include <pthread.h> #include <semaphore.h> #include & ...
- 简单的TCPIP 客户端 服务器
// soClient.cpp : Defines the entry point for the console application. // #include "stdafx.h&qu ...
- Java中自定泛型方法
泛型用到哪些集合:List Set Map List<String> list=new ArraList<String>(); list.add("美女") ...
- 再看.net本质
1.[资源的地址-通用资源标识符] 我们在地址栏中输入的内容称为通用资源标识符(Universal Resource Identifier,URI),它有很多种形式,在Web中我们通常使用称为统一资源 ...
- ref传递
下面通过一个排序的小栗子来分析ref传递: static void Main(string[] args) { ,,,,}; int num; Console.WriteLine("请输入您 ...
- Dynamic AX 4.0 用户组权限SecurityKey
UserId _userId = "IT001"; UserGroupId _userGroupId = "ABC_1"; DomainId _domainId ...
- Server2003安装SP2补丁提示密钥无效的解决方法
机器一直没有打SP2的补丁.几天要安装一个程序,还非要SP2不可.没办法.居然打补丁的时候出现了这样的错误信息: --------------------------- Service Pack 2 ...
- 一个完整的菜谱客户端(android源码)(有独立后台)
该源码是自己写的,是一个完整的菜谱类客户端.功能简单比较简单,界面比较丑,自己乱拼接的,只为学习用.功能相对完整,数据来自独立后台,通过http协议获取,全部来自真实数据.代码里面有获取数据的相应ur ...
- win2003以isapi的方式配置php+mysql环境(安装了shopEX)
一.准备相关组件 mysql-installer-community-5.5.29.0.zip php-5.2.17-Win32-VC6-x86 ZendOptimizer-3.3.3-Windows ...