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, ...
随机推荐
- 【练习】如何显示本地主机上的MySQL客户机版本
在终端窗口以oracle用户身份登录 [root@enmo ~]# su - oracle [oracle@enmo ~]$ mysql -V mysql Ver , for Linux (x86_6 ...
- 洛谷P1519 穿越栅栏 Overfencing
P1519 穿越栅栏 Overfencing 69通过 275提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 USACO是100分,洛谷是20分 为什么 ...
- 关闭GS选项,解决注入后崩溃
利用CreateRemoteThread向进程注入远程代码时,一般会有以下两种做法: 利用LoadLibrary在目标进程加载指定的DLL 将代码复制到目标进程,然后启动这段代码 上面的第二种方法其实 ...
- LARGE_INTEGER
#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR ipCm ...
- 网络资源管理系统LANsurveyor实战体验
网络资源管理系统LANsurveyor实战体验 用于生成网络拓扑并管理网络各种设备的软件很多(例如上一篇文章展示的CiscoWorks 2000,我还介绍过开源领域的Cheops-NG),今天为大家介 ...
- Lamp源码包安装实录
Lamp源码包安装实录 附件中是安装步骤,下载站点里包含视频(http://down.51cto.com/data/460776) 本文出自 "李晨光原创技术博客" 博客,请务必保 ...
- WP8_读写XML
/// <summary> /// WP手机,XML读写类 /// </summary> public class WPXmlRW { /// <summary> ...
- Sunglasses
It's hot this summer. It also reminds me of one case about sunglasses. She was new to this company a ...
- vsftp快速配置
/etc/vsftpd/vsftpd.confanonymous_enable=YESlocal_enable=YESwrite_enable=YESlocal_umask=022dirmessage ...
- linq to xml 基本操作
使用XDocument类来进行简单的xml操作,用于软件参数的设置保存. using System; using System.Collections.Generic; using System.Li ...