首页 / ORACLE / oracle 表迁移方法 (一)
oracle 表迁移方法 (一)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了oracle 表迁移方法 (一),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3375字,纯文字阅读大概需要5分钟。
内容图文
在生产系统中,因业务需求,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 表迁移方法 (一)
标签:
本文系统来源:http://www.cnblogs.com/hankyoon/p/5174589.html
内容总结
以上是互联网集市为您收集整理的oracle 表迁移方法 (一)全部内容,希望文章能够帮你解决oracle 表迁移方法 (一)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。