Home Database Mysql Tutorial Oracle 日志记录(联机日志/非联机日志)

Oracle 日志记录(联机日志/非联机日志)

Jun 07, 2016 pm 05:04 PM

Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日

查看方法:select name,log_mode from v$database;

Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日志里。一般数据库至少要有2个联机重做日志组。当一个联机重做日志组被写满的时候,就会发生日志切换,这时联机重做日志组2成为当前使用的日志,当联机重做日志组2写满的时候,又会发生日志切换,去写联机重做日志组1,就这样反复进行。
如果数据库处于非归档模式,联机日志在切换时就会丢弃. 而在归档模式下,当发生日志切换的时候,被切换的日志会进行归档。比如,,当前在使用联机重做日志1,当1写满的时候,发生日志切换,开始写联机重做日志 2,这时联机重做日志1的内容会被拷贝到另外一个指定的目录下。这个目录叫做归档目录,拷贝的文件叫归档重做日志。
数据库使用归档方式运行时才可以进行灾难性恢复。
归档日志模式和非归档日志模式的区别
非归档模式只能做冷备份,并且恢复时只能做完全备份.最近一次完全备份到系统出错期间的数据不能恢复.
归档模式可以做热备份,并且可以做增量备份,可以做部分恢复.
用ARCHIVE LOG LIST 可以查看期模式状态时归档模式还是非归档模式.

改变归档模式到非归档模式:
1)SQL>SHUTDOWN NORMAL/IMMEDIATE;
2)SQL>START MOUNT;
3)SQL>ALTER DATABASE NOARCHIVELOG;
4)SQL>ALTER DATABASE OPEN;

启用自动归档: LOG_ARCHIVE_START=TRUE
归档模式下,日志文件组不允许被覆盖(重写),当日志文件写满之后,如果没有进行手动归档,那么系统将挂起,知道归档完成为止.
这时只能读而不能写.
运行过程中关闭和重启归档日志进程
SQL>ARCHIVE LOG STOP
SQL>ARCHIVE LOG START

手动归档: LOG_ARCHIVE_START=FALSE
归档当前日志文件
SQL>ALTER SYSTEM ARCHIVE LOG CURRENT;
归档序号为052的日志文件
SQL>ALTER SYSTEM ARCHIVE LOG SEQUENCE 052;
归档所有日志文件
SQL>ALTER SYSTEM ARCHIVE LOG ALL;
改变归档日志目标
SQL>ALTER SYSTEM ARCHIVE LOG CURRENT TO '&PATH';

1------------------------------------------------------
某DBA告诉我这样可以不写LOG:
alert tablename nologgin;
insert into tablename (select ...)
注意:insert语句后面必须是‘select...’语句,否则无效

2------------------------------------------------------
NOLOGING选项只是在direct-load模式下才不写redo log,nomal DML无效

3------------------------------------------------------
alter table tb_txn_log nologging,然后改回来alter table tb_txn_log logging这种模式
会影响联机交易

4------------------------------------------------------
 insert into test1 nologging select * from dba_objects
 alter table test1 nologging
 insert into test1  select * from dba_objects

5------------------------------------------------------

关于nologging的用法
有许多朋友误已写SQL或把表的属性加NOLOGGING,就可以不采成日志。这是一个误解。

在数据迁移或大量的数据insert入库时,由于大量数据的insert或修改,经常引起redo log sync的等待,造成数据库性能缓慢。
因为许多朋友对NOLOGGING的误解,所以许多人在insert数据时,在SQL后加nologging,想通过该用法使操作不采生日记录。但无效果。
这里讨论nologging的具体用法:

数据库操作,只有如下几种情况下不产成redo记录:
1、用sql*load的direct load方式时,不采用redo记录
2、用insert的direct方式,即在append方式insert( insert append可以实现直接路径加载,速度比常规加载方式快很多。但有一点需要注意: insert append时在表上加“6”类型的Exclusive锁,会阻塞表上的所有DML语句。因此在有业务运行的情况下要慎重使用.在使用了append选项以后,insert数据会直接加到表的最后面,而不会在表的空闲块中插入数据。
使用append会增加数据插入的速度。
的作用是在表的高水位上分配空间,不再使用表的extent中的空余空间
append 属于direct insert,归档模式下append+table nologging会大量减少日志,非归档模式append会大量减少日志,append方式插入只会产生很少的undo
不去寻找 freelist 中的free block , 直接在table HWM 上面加入数据。)
3、create table .... as select
4、create index
5、alter table ... move partition
6、alter table ... split partition
7、alter index ... split partition
8、alter index ... rebuild
9、alter index ... rebuild partition
10、INSERT, UPDATE, and DELETE on LOBs in NOCACHE NOLOGGING mode stored out of line

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles