Oracle 增加日志组,日志成员的一些命令2012-05-14 13:421、增加日志组: alter database add logfile group 4
Oracle 增加日志组,日志成员的一些命令
2012-05-14 13:42
1、增加日志组:
alter database add logfile group 4 '/oradata/oracle/oradata/oracle_sid/redo04.log' size 100M;
2、改变日志组的大小(
首先看下归档状态:
SQL> select group#,thread#,members,archived,status from v$log;
GROUP# THREAD# MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
1 1 1 YES INACTIVE
2 1 1 YES INACTIVE
3 1 1 NO CURRENT
4 1 1 YES UNUSED
4 rows selected.
其次DROP GROUP 1(此时最好是别DROP GROUP3,至于什么后果,,我没有往这方向TEST。)
SQL> alter database drop logfile group 1;
Database altered.
再删除redo01.log
SQL> !rm /oradata/oracle/oradata/NC5X/redo01.log
最后增加redo01.log:
SQL> alter database add logfile group 1 '/oradata/oracle/oradata/ORACLE_SID/redo01.log' size 100M;
SQL> select group#,thread#,members,archived,status from v$log;
GROUP# THREAD# MEMBERS ARC STATUS
---------- ---------- ---------- --- ----------------
1 1 1 YES UNUSED
2 1 1 YES INACTIVE
3 1 1 NO CURRENT
4 1 1 YES UNUSED
4 rows selected.
此时,切换下日志:
SQL> alter system switch logfile;
System altered.
注意:alter system switch logfile 和alter system archive log current这两个切换的区别。
alter system switch logfile 是不等待归档完成就switch logfile。如果database尚未开启archive log mode。那用这个切换是毋庸置疑了。另外,也是对单实例database和RAC模式下当前实例执行日志切换。
而alter system archive log current则需要等待归档完成才switch logfile。会对中所有实例执行日志切换。
整体上说来,在自动归档的库里,两个命令的所产生的结果几乎一样。有区别的是alter system archive log current所用的时间会比alter system switch logfile 的长。
3、增加日志组成员:
SQL> alter database add logfile member '/oraback/logbackup/redo01_b.log' to group 1;
Database altered.
注意:alter 语句中不可设定redo01_b.log的大小。
SQL> alter database add logfile member '/oraback/logbackup/redo01_b.log' size 100M to group 1;
alter database add logfile member '/oraback/logbackup/redo01_b.log' size 100M to group 1
*
ERROR at line 1:
ORA-00946: missing TO keyword。
Alter语句运行之后,生成的Redo01_b.log的大小与redo01.log的大小一致。
路径可以选择与默认路径不一致。
最后,得声明一下:可以同时增加几个日志组。也可以同时增加几个日志组成员。语句格式如下:
ALTER DATABASE ADD LOGFILE '/LOCATION_DUEST/REDO01.LOG' SIZE 10M,''/LOCATION_DUEST/REDO02.LOG' SIZE 10M... ...;依次类推。
增加成员也类似。不在赘述。
4、删除日志组及日志组成员:
原则:删除前必须遵守如下原则,每个实例必须至少有两个日志组;当一个组处于ACTIVE或者CURRENT的状态时不可删除;删除日志组的操作只对数据库进行更改,操作系统的文件尚未删除;当删除时适用DROP LOGFILE GROUP N语句时,此时GROUP N内的所有成员都将被删除。
ALTER DATABASE DROP LOGFILE GROUP N;
删除日志成员的原则:当你删除一个是该组中最后一个成员的时候,你不能删除此成员;当组的转台处于current的状态时,不能删除组成员;在归档模式下,必须得归档之后才能删除;删除日志组成员的操作只对数据库进行更改,操作系统的文件尚未删除
ALTER DATABASE DROP LOGFILE MEMBER '/LOCATION_DUST/REDO0N_N.LOG';

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
