应用环境: 我的一个表被人不小心误删除了,这时候,我不可以把整个库都恢复回去,那样太麻烦了。 所以现在我就从新到一个新库,只将这一个数据文件拷贝过来恢复。 那我们Oracle在恢复文件的时候是不可以只恢复一部分数据文件的,因为oracle 要保证数据文件
应用环境: 我的一个表被人不小心误删除了,这时候,我不可以把整个库都恢复回去,那样太麻烦了。
所以现在我就从新到一个新库,只将这一个数据文件拷贝过来恢复。
那我们Oracle在恢复文件的时候是不可以只恢复一部分数据文件的,因为oracle 要保证数据文件块头信息一致,所以如果我们要恢复部分文件的话,就得采取以下这种方法:
可以另起一个库,再把要恢复的数据文件拷贝过来,恢复。(当然不单单是该数据文件,还要包括system表空间,undo表空间)
1)另起一个库很简单,可以搞出参数文件,在参数文件中添加一行*.db_unique_name='rt'和修改控制文件路径。
$ORACLE_SID=rt sqlplus / as sysdba >startup nomount pfile='/tmp/pfile.ora'
接着控制文件怎么办呢,
2)当然我们可以将之前备份的数据文件直接恢复到我们配置的参数文件中控制文件的路径。
恢复控制文件:
rman target > restore controlfile to '/u01/app/oracle/oradata/test/rt_con01.ctl' from '/tmp/FULL_04pe7jue_1_1.bak';
那现在可以mount了。
现在是不可以open的,如果你现在open,他就会把原来的logfile 覆盖,那肯定原来的那个库会出问题。
3)我们这里要做的就是先恢复数据文件:
在rman中用到一个newname,首先确定原来的system,undo,还有要恢复的表空间文件号。
run { allocate channel di type disk; set newname for datafile 1 to '/tmp/disk1/system01.dbf'; set newname for datafile 3 to '/tmp/disk1/undotbs01.dbf'; set newname for datafile 9 to '/tmp/disk1/test_01.dbf'; restore datafile 1,3,9; }
当然你执行上面会报错,因为我们是新创建的控制文件,所以要注册一下:
rman >catalog start with '/tmp/FULL_04pe7jue_1_1.bak'
4) 然后在主库更改redo日志:
select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ NEXT_TIME ------------------- 1 1 75 52428800 512 2 YES INACTIVE 4215102 2014-07-26:22:18:25 4215195 2014-07-26:22:19:55 2 1 74 52428800 512 2 YES INACTIVE 4211699 2014-07-26:20:55:55 4215102 2014-07-26:22:18:25 3 1 76 52428800 512 2 NO CURRENT 4215195 2014-07-26:22:19:55 2.8147E+14
当前正在用的是group 3,那我们可以删除group1;
SYS@_connect_identifier>alter database drop logfile group 1; 数据库已更改。 SYS@_connect_identifier>alter database add logfile group 1('/u01/app/oracle/oradata/test/mredo01.log') size 60m reuse; 数据库已更改。
跟着删除group 2 :
SYS@_connect_identifier > alter database drop logfile group 2; 数据库已更改。 SYS@_connect_identifier > alter database add logfile group 2('/u01/app/oracle/oradata/test/mredo02.log') size 60m reuse; 数据库已更改。
那3就要跟着切换日志,做完全检查点了:
SYS@_connect_identifier>select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ NEXT_TIME ------------------- 1 1 0 62914560 512 1 YES UNUSED 0 0 2 1 0 62914560 512 1 YES UNUSED 0 0 3 1 76 52428800 512 2 NO CURRENT 4215195 2014-07-26:22:19:55 2.8147E+14 SYS@_connect_identifier>alter system switch logfile; 系统已更改。 SYS@_connect_identifier>alter system checkpoint; 系统已更改。 SYS@_connect_identifier>alter database drop logfile group 3; 数据库已更改。 SYS@_connect_identifier>alter database add logfile group 3('/u01/app/oracle/oradata/test/mredo03.log')size 60m reuse; 数据库已更改。
将备库中不用数据文件更改掉
alter database datafile 2 offline drop;
alter database datafile 4 offline drop;
alter database datafile 5 offline drop;
alter database datafile 6 offline drop;
alter database datafile 8 offline drop;
alter database datafile 10 offline drop;
6)备库更改数据文件路径和归档日志文件路径:
SYS@_connect_identifier>alter database rename file '/u01/app/oracle/oradata/test/system01.dbf' to '/tmp/disk1/system01.dbf' 2 ; 数据库已更改。 SYS@_connect_identifier>alter database rename file '/u01/app/oracle/oradata/test/undotbs01.dbf' to '/tmp/disk1/undotbs01.dbf'; 数据库已更改。 SYS@_connect_identifier>alter database rename file '/u01/app/oracle/oradata/test/test_01' to '/tmp/disk1/test_01.dbf'; 数据库已更改。 SYS@_connect_identifier>set LOGSOURCE '/tmp/disk1/arch';
7)恢复日志文件:
SYS@_connect_identifier >recover database using BACKUP controlfile until cancel; ORA-00279: 更改 4203853 (在 07/24/2014 19:57:38 生成) 对于线程 1 是必需的 ORA-00289: 建议: /tmp/disk1/arch/1_73_831746264.dbf ORA-00280: 更改 4203853 (用于线程 1) 在序列 #73 中
检查数据文件路径,日志文件路径:
SYS@_connect_identifier >select * from v$dbfile; FILE# NAME ---------- ---------------------------------------- 10 /u01/app/oracle/oradata/test/rman01.dbf 9 /tmp/disk1/test_01.dbf 8 /tmp/perstat.ora 6 /home/oracle/trans.dbf 5 /u01/app/oracle/oradata/test/example01.d bf 4 /u01/app/oracle/oradata/test/users01.dbf 3 /tmp/disk1/undotbs01.dbf 2 /u01/app/oracle/oradata/test/sysaux01.db f FILE# NAME ---------- ---------------------------------------- 1 /tmp/disk1/system01.dbf 已选择9行。
8)打开数据库,任务结束:
SYS@_connect_identifier > alter database open resetlogs; 数据库已更改。 SYS@_connect_identifier >select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------ NEXT_TIME ------------------- 1 1 1 52428800 512 2 NO CURRENT 4203854 2014-07-27:12:39:11 2.8147E+14 2 1 0 52428800 512 2 YES UNUSED 0 0 3 1 0 52428800 512 2 YES UNUSED 0 0 SYS@_connect_identifier >

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc


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

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version
