flashback drop 闪回下降(删除)
SQL> show parameter recyclebin
SQL> purge recyclebin;(清除回收站)
SQL> create tablespace tbs01 datafile '/home/oracle/tbs01.dbf' size 5M;
SQL> create table t1 tablespace tbs01 as select * from dba_objects where rownum<=20000;
SQL> create index t1_object_id_idx on t1(object_id) tablespace tbs01;
SQL> select INDEX_NAME from user_indexes where TABLE_NAME='T1';
SQL> drop table t1;
SQL> select table_name from user_tables;
SQL> show recyclebin
SQL> select object_name, original_name, type, droptime from user_recyclebin; 包含index
SQL> select count(*) from "BIN$IyKOcy5jPo7gUwEAqMCBEg==$0";
SQL> flashback table t1 to before drop;
SQL> select INDEX_NAME from user_indexes where TABLE_NAME='T1';
SQL> alter index "BIN$LRyc7hA1JaPgUwEAqMDzWw==$0" rename to T1_OBJECT_ID_IDX; 恢复index名称
重名的处理:
SQL> flashback table "BIN$IyKOcy5jPo7gUwEAqMCBEg==$0" to before drop;
SQL> flashback table t1 to before drop rename to t2;
SQL> drop table t1;
SQL> show recyclebin 在回收站中
SQL> create table t2 tablespace tbs01 as select * from dba_objects where rownum<=30000;
SQL> show recyclebin t1被覆盖
SQL> drop table t2 purge;
SQL> purge recyclebin
flashback transaction query(闪回事务查询)
SQL> alter database add supplemental log data;
SQL> alter database add supplemental log data (primary key) columns;
SQL> create table t1(x int);
SQL> insert into t1 values (1);
SQL> commit;
SQL> update t1 set x=11 where x=1; 误操作的事务
SQL> commit;
SQL> insert into t1 values (2);
SQL> commit;
select versions_starttime, versions_endtime, versions_xid, versions_operation, x
from t1
versions between scn minvalue and maxvalue
order by versions_starttime; 获取误操作事务的xid
SQL> select UNDO_SQL, OPERATION from flashback_transaction_query where xid='02000F0059040000';
flashback database(闪回数据库)
SQL> shutdown immediate
SQL> startup mount
SQL> alter database flashback on; 数据库在归档模式下
SQL> show parameter db_flashback_retention_target
SQL> select OLDEST_FLASHBACK_TIME from v$flashback_database_log;
SQL> create table t1(x int);
SQL> insert into t1 values (1);
SQL> commit;
SQL> select dbms_flashback.get_system_change_number from dual;
SQL> truncate table t1;
SQL> create table after_truncate(x int); 其他正确操作
SQL> select OLDEST_FLASHBACK_TIME, OLDEST_FLASHBACK_SCN from v$flashback_database_log; 确认是否在恢复范围
SQL> shutdown abort
SQL> startup mount
SQL> flashback database to scn 1495195;
SQL> alter database open resetlogs;
SQL> select * from t1;
SQL> select * from after_truncate; 消失
移动数据
sqlloader
SQL> create table t1(id int constraint t1_id_pk primary key, name varchar2(20), salary int constraint t1_salary_ck check(salary>0));
$ vi ~/loader.dat
100,"abc",1000
100,"def",2000
102,"xyz",-1000
em中常规导入,自动处理违反约束的记录

em中直接导入
SQL> select CONSTRAINT_NAME, STATUS from user_constraints where TABLE_NAME='T1';
SQL> select INDEX_NAME, STATUS from user_indexes where TABLE_NAME='T1';
SQL> alter table t1 enable validate constraint T1_SALARY_CK; 失败
SQL> @?/rdbms/admin/utlexpt1.sql
处理check约束:
SQL> alter table t1 enable validate constraint T1_SALARY_CK exceptions into exceptions;
SQL> select * from t1 where rowid in(select ROW_ID from exceptions);
SQL> update t1 set salary=abs(salary) where id=102;
SQL> truncate table exceptions;
SQL> alter table t1 enable validate constraint T1_SALARY_CK exceptions into exceptions;
处理pk约束:
SQL> alter table t1 disable novalidate constraint T1_ID_PK;
SQL> alter table t1 enable validate constraint T1_ID_PK exceptions into exceptions;
SQL> select * from t1 where rowid in(select ROW_ID from exceptions);
SQL> update t1 set id=101 where name='def';
SQL> truncate table exceptions;
SQL> alter table t1 enable validate constraint T1_ID_PK exceptions into exceptions;
SQL> select INDEX_NAME, STATUS from user_indexes where TABLE_NAME='T1';

Oracle课程档案,第十七天的更多相关文章

  1. Oracle课程档案,第十六天

    restore:恢复文件 recover: 恢复日志 丢失current日志组(正常关闭数据库):故障:SQL> select group#, status from v$log; 确认curr ...

  2. Oracle课程档案,第十四天

    备份数据文件:SQL> select file_id, file_name from dba_data_files; backup:备用(备份) datafile:数据文件 backup tab ...

  3. Oracle课程档案,第十五天

    restore:恢复数据文件 recover:写日志 1.redo(roll forward)重做 (前进) 2.undo(roll back) 撤销 (回滚) cp -r:删除一个目录 archiv ...

  4. Oracle课程档案,第十三天

    配置可恢复性: ontrol_files:控制文件 parameter:参数 show:显示 select name from v$database; 查看当前的数据库★★ 控制文件SQL> s ...

  5. Oracle课程档案,第十二天

    死锁是由于两个对象在拥有一份资源的情况下申请另一份资源, 而另一份资源恰好又是这两对象正持有的,导致两对象无法完成操作,且所持资源无法释放. 阻塞是由于资源不足引起的排队等待现象. unso:撤销 c ...

  6. Oracle课程档案。第十一天

    读一致性:oracle通过多版本与闪回机制保证读一致性.保证从某个时间点开始查询是一致的.在Oracle中主要通过SCN版本号来控制系统修改的版本,典型的例子是我们可以通过在同一个查询中得到同一个对象 ...

  7. Oracle课程档案,第十天

    用户管理 Authentication: 身份验证 AAA:Authentication: 身份验证 Authorization: 权限管理 Audition: 审计 grant:授权 unset:撤 ...

  8. Oracle课程档案,第九天

    lsnrctl status:查看监听状态 Oracle网络配置三部分组成:客户端,监听,数据库 配置文件:$ vi $ORACLE_HOME/network/admin/listener.ora v ...

  9. Oracle课程档案,第八天

    存储管理 查询块的大小:show parameter db_block_size database:数据库 tablespace:表空间 datafile:数据文件 segments:段 extent ...

随机推荐

  1. 【Java-JPA】让Springboot启动不检查JPA的数据源配置

    #https://stackoverflow.com/questions/24074749/spring-boot-cannot-determine-embedded-database-driver- ...

  2. Delphi及C++Builder经典图书一览表(持续更新中2018.01.02)

    序号 书名 原版书名 作者 译者 出版社 页数 年代 定价 备注 1 C++Builder 5程序设计大全 C++Builder 5 Developer's Guide Jarrod Hollingw ...

  3. mysql数据类型转换

    --CAST(xxx AS 类型) --CONVERT(xxx,类型) --#浮点型转化为int --i='3.35' --cast(i as signed) --cast(sum(money/100 ...

  4. spring boot 搭建

    http://www.ityouknow.com/springboot/2018/06/12/spring-boo-java-simple.html 在http://start.spring.io/下 ...

  5. ios app qbw.plist demo

    qbw.plist <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC ...

  6. Ubuntu下创建新用户后,不能使用管理员用户下安装的Anaconda

    解决办法: 将管理员用户下Anaconda的安装环境添加到新用户下的环境变量里,具体操作: 系统切换到新用户下: vim .bashrc #添加Anaconda的环境变量 source .bashrc ...

  7. Elasticsearch学习笔记——分词

    1.测试Elasticsearch的分词 Elasticsearch有多种分词器(参考:https://www.jianshu.com/p/d57935ba514b) Set the shape to ...

  8. org.hibernate.InvalidMappingException: Could not parse mapping document from无法创建sessionFactory

    把 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" 改为 "http://hibernate.sourc ...

  9. minicom for Mac 配置

    安装:brew install minicom 配置: 串口是:dev/tty.usbserial minicons -s 配置一下: 流控要关掉,不然输入不了

  10. ABBYY PDF Transformer+功能概述

    ABBYY PDF Transformer+是一个新的.全面的巧妙解决PDF文档的工具,它将泰比的光学字符识别(OCR)技术和Adobe®PDF技术完美结合,以确保实现便捷地处理任何类型的PDF文件, ...