Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

11G flashback database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The first scenario library is used to train or test the environment and restore the original appearance after testing.

SYS@ odb > archive log list

Databaselog mode No Archive Mode

Automaticarchival Disabled

Archivedestination USE_DB_RECOVERY_FILE_DEST

Oldestonline log sequence 220

Currentlog sequence 222

SYS@odb > show parameter recover / / flashback zone

NAME TYPE VALUE

Db_recovery_file_dest string / u01/app/oracle/fast_recovery_area

Db_recovery_file_dest_size big integer 4977M

Db_unrecoverable_scn_tracking boolean TRUE

Recovery_parallelism integer 0

[oracle@wenxi~] $cd / u01/app/oracle/fast_recovery_area

[oracle@wenxifast_recovery_area] $ls

Odb

SYS@odb > show parameter flashback / / flashback database

NAME TYPE VALUE

-

Db_flashback_retention_target integer 1440 (minutes: 24 hours)

SYS@ odb > select flashback_onfrom v$database

FLASHBACK_ON

-

NO

SYS@odb > shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLEinstance shut down.

SYS@odb > startup mount

ORACLEinstance started.

TotalSystem Global Area 1603411968 bytes

FixedSize 2253664 bytes

VariableSize 905972896 bytes

DatabaseBuffers 687865856 bytes

RedoBuffers 7319552 bytes

Databasemounted.

SYS@odb > alter database flashback on

Alterdatabase flashback on

*

ERRORat line 1:

ORA-38706:Cannot turn on FLASHBACK DATABASE logging.

ORA-38707:Media recovery is not enabled.

SYS@odb > alter database archivelog

Databasealtered.

SYS@odb > alter database flashback on

Databasealtered.

SYS@odb > alter database open

Databasealtered.

Check that a new file is generated after going to the flashback directory

[oracle@wenxifast_recovery_area] $ls

Odb ODB

[oracle@wenxifast_recovery_area] $cd ODB/

[oracle@wenxiODB] $ls

Flashback

[oracle@wenxiODB] $cd flashback/

O1_mf_cwp9ykby_.flb o1_mf_cwp9ynj5_.flb / / flashback log

1. Use the test environment together

(1) establish a reduction point

SYS@odb > create restore point hyd2016 guarantee flashback database

Restorepoint created.

(2) View the data in the table

SYS@odb > SELECT NAME,SCN,TIME,DATABASE_INCARNATION#

DI,GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE/1024/1024/1024 FROM V$RESTORE_POINT WHEREGUARANTEE_FLASHBACK_DATABASE='YES'

NAME SCN TIME DI GUASTORAGE_SIZE/1024/1024/1024

-

HYD2016 5539977 04-SEP-16 03.52.53.0 1 YES. 048828125

00000000 AM

(3) perform database operation

TEST_FB@odb > create table T001 as select * from shanhui

TEST_FB@odb > create table t002 as select * from shanhui

TEST_FB@odb > delete from test

10rows deleted.

TEST_FB@odb > commit

Commitcomplete.

TEST_FB@odb > select * from test

Norows selected

(4) flashback the database. Close the database and start it to mount for flashback.

SYS@odb > shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLEinstance shut down.

SYS@odb > startup mount

ORACLEinstance started.

TotalSystem Global Area 1603411968 bytes

FixedSize 2253664 bytes

VariableSize 905972896 bytes

DatabaseBuffers 687865856 bytes

RedoBuffers 7319552 bytes

Databasemounted.

SYS@ odb > flashback database torestore point hyd2016

Flashbackcomplete.

(5) Open it in read-only mode, log in to test_fb account, and check whether the data meets the requirements.

SYS@ odb > alter database open readonly

Databasealtered.

TEST_FB@ odb > conn test_fb/test_fb

Connected.

TEST_FB@ odb > select * from cat

TABLE_NAME TABLE_TYPE

-

SHANHUI TABLE

TEST TABLE

2 rowsselected.

(6) reopen the database after checking the data

SYS@odb > shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLEinstance shut down.

SYS@odb > startup mount

ORACLEinstance started.

TotalSystem Global Area 1603411968 bytes

FixedSize 2253664 bytes

VariableSize 905972896 bytes

DatabaseBuffers 687865856 bytes

RedoBuffers 7319552 bytes

Databasemounted.

SYS@odb > alter database open

Alterdatabase open

*

ERRORat line 1:

ORA-01589:must use RESETLOGS or NORESETLOGS option for database open

SYS@ odb > alter database open resetlogs

Databasealtered

In the second scenario, the data file is switched to experiment. The original data file has data, and the data in the table is deleted in order to test the new data.

(1) Simulation data

TEST_FB@odb > select * from cat

TABLE_NAME TABLE_TYPE

-

SHANHUI TABLE

TEST TABLE

TEST_FB@odb > select count (*) from test

COUNT (*)

-

1310720

(2) recording timestamp

TEST_FB@odb > select to_char (systimestamp,'yyyy-mm-dd hh34:mi:ss') from dual

TO_CHAR (SYSTIMESTAM

-

2016-09-0405 purl 09purl 55

View Siz

TEST_FB@odb > select segment_name,bytes from user_segments where segment_name='TEST'

SEGMENT_NAME BYTES

-

TEST 142606336

(3), truncate test table

TEST_FB@odb > truncate table test

TEST_FB@odb > select * from test

No rows selected

Flashback log

[oracle@wenxi flashback] $ls-l

Total 102432

-rw-r-. 1oracle oinstall 52445184 Sep 4 04:41o1_mf_cwp9ykby_.flb

-rw-r-. 1oracle oinstall 52445184 Sep 4 03:43o1_mf_cwp9ynj5_.flb

(4) add a piece of data to test

TEST_FB@ odb > insert into test select * fromall_objects where rownumcommit

TEST_FB@ odb > select count (*) from test

COUNT (*)

-

one

(5) after the test, you can flash back to the state of the previous table

SYS@ odb > shutdown immediate

Database closed.

Databasedismounted.

ORACLE instanceshut down.

SYS@ odb > startup mount

ORACLE instancestarted.

Total SystemGlobal Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 905972896 bytes

DatabaseBuffers 687865856 bytes

Redo Buffers 7319552 bytes

Database mounted.

SYS@odb > Flashback database to timestamp to_timestamp ('2016-09-0405 mm-dd hh34:mi:ss' 09-09-0405)

Flashbackcomplete.

SYS@ odb > alter database open read only

Database altered.

(6) log in to the test_fb account to check, which is the same as the original data

TEST_FB@odb > conn test_fb/test_fb

Connected.

TEST_FB@odb > select * from cat

TABLE_NAME TABLE_TYPE

-

SHANHUI TABLE

TEST TABLE

2 rows selected.

TEST_FB@odb > select count (*) from test

COUNT (*)

-

1310720

(7) officially open the database

SYS@ odb > shutdown immediate

Database closed.

Databasedismounted.

ORACLE instanceshut down.

SYS@ odb > startup mount

ORACLE instancestarted.

Total SystemGlobal Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 905972896 bytes

DatabaseBuffers 687865856 bytes

Redo Buffers 7319552 bytes

Database mounted.

SYS@ odb > alter database open resetlogs

Database altered.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report