Oracle課程檔案,第十七天

2022-08-10 04:39:17 字數 4327 閱讀 4258

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';

打卡第十七天

第二次了,又沒過.有時候會有一種失敗感,這幾年好像什麼都沒做好,過的好像也不是很開心。昨天兵查過成績後心情就低落起來了,尤其是聽到晨晨得知她沒過時發出的驚訝聲音 你竟然沒過?時,心情立馬跌到了谷底,回到宿舍就再也繃不住了,大哭了一場,媽媽打 詢問情況,看到女兒哭的傷心,竟也無措起來,不知如何安慰。於...

失業第十七天

失業過了十七天,今天進行了第三場面試,說來也巧有好幾個同學在面試的公司,哈哈哈 找個角落了解下內幕 每個公司都有各自的風格,每個面試官也有各自的特點,才面了三家公司就感受到了完全不同的形式,只有hr面試的內容基本相似,簡單說說吧 第一家 技術面試筆試 上機面試內容就聊聊題目,接著聊聊學校生活,在聊的...

寒假第十七天

python連線資料庫 今天學習了一下python如何連線資料庫以及增刪改查 首先我用的是pymysql,是python連線mysql的乙個庫 首先先得安裝pymysql 命令pip install pymysql 具體 import pymysql 引用pymysql模組 開啟資料庫連線db py...