SQL Server中误删除数据的恢复本来不是件难事,从事务日志恢复即可。但是,这个恢复需要有两个前提条件:
2 数据库的恢复模式(Recovery mode)是“完整(Full)”。
针对这两个前提条件,会有三种情况:
情况一、如果这两个前提条件都存在,通过SQL语句只需三步就能恢复(参考文章),无需借助第三方工具。
a) 备份当前数据库的事务日志:BACKUP LOG [数据库名] TO disk= N'备份文件名' WITH NORECOVERY
b) 恢复一个误删除之前的完全备份:RESTORE DATABASE [数据库名] FROM DISK = N'完全备份文件名' WITH NORECOVERY, REPLACE
c) 将数据库恢复至误删除之前的时间点:RESTORE LOG [数据库] FROM DISK = N'第一步的日志备份文件名' WITH STOPAT = N'误删除之前的时间点' , RECOVERY
情况二、如果第1个前提条件不存在,第2个前提条件存在,需要借助第三方工具。
情况三、如果第2个前提条件不存在,无法恢复。所以,一定要将数据库恢复模式设置为“完整(Full)”。
我现在面临的是第二种情况,需要找第三方工具。
开始找的是Log Explorer for SQL Server,不支持SQL Server 2008。
后来找的是SQL Log Rescue,也不支持SQL Server 2008。
接着找到的是SysTools SQL Recovery,支持SQL Server 2008,但需要购买,Demo版并没有数据恢复功能。
最终在officerecoverycom上找到Recovery for SQL Server,虽然也是商业软件,需要购买,但Demo版可以恢复数据,只要数据库文件不超过24Gb。幸好朋友的数据库文件不大,用它完成了误删除数据的恢复。
下面分享一下用Recovery for SQL Server进行恢复的 *** 作步骤:
1 运行Recovery for SQL Server
2 点击菜单中的 File > Recover,选择要恢复的数据库的数据文件(mdf)
3 Next > Next,进入 Recovery Configuration 界面,选择Custom(选择了Custom才可以选择从日志中恢复误删除的数据)。
4 Next 进入 Recovery options 窗口,选中 Search for deleted records,并选择要恢复的数据库的日志文件路径(log file path)。
5 Next 并选择目标文件夹(Destination folder),用于存放恢复过程中生成的SQL语句与bat文件。
6 点击Start,开始恢复 *** 作(在上一步选择的目标文件夹中生成相应的SQL文件与Bat文件),然后,出现 SQL Server Database Creation Utility 窗口。
7 Next,选择被恢复数据存放的目标数据库。
8 Next, 选择 Import availiable data from both database and log files
9 Next, Next, 然后就完成数据的恢复!
yze_p sql
yze_p sqlBEGIN SYS DBMS_UTILITY ANALYZE_SCHEMA ( &OWNER PUTE ); END; /
pop_vol sql
pop_vol sqlinsert into utl_vol_facts select table_name NVL ( num_rows ) as num_rows trunc ( last_ yzed ) as meas_dt from all_tables
or just user_tableswhere owner in ( &OWNER )
or a ma separated list of owners
/ mit /
C 每周处理程序
nextext sql
nextext sql To find tables that don t match the tablespace default for NEXT extent The implicit rule here is that every table in a given tablespace should use the exact same value for NEXT which should also be the tablespace s default value for NEXT his tells us what the setting for NEXT is for these objects today / /SELECT segment_name segment_type ds next_extent as Actual_Next dt tablespace_name dt next_extent as Default_Next FROM dba_tablespaces dt dba_segments ds WHERE dt tablespace_name = ds tablespace_name AND dt next_extent !=ds next_extent AND ds owner = UPPER ( &OWNER ) ORDER BY tablespace_name segment_type segment_name;
existext sql
existext sql To check existing extents This tells us how many of each object s extents differ in size from the tablespace s default size If this report shows a lot of different sized extents your free space is likely to bee fragmented If so this tablespace is a candidate for reanizing / /SELECT segment_name segment_type count() as nr_exts sum ( DECODE ( dx bytes dt next_extent ) ) as nr_illsized_exts dt tablespace_name dt next_extent as dflt_ext_size FROM dba_tablespaces dt dba_extents dx WHERE dt tablespace_name = dx tablespace_name AND dx owner = &OWNER GROUP BY segment_name segment_type dt tablespace_name dt next_extent;
No_pk sql
no_pk sql To find tables without PK constraint / /SELECT table_name FROM all_tables WHERE wner = &OWNER MINUS SELECT table_name FROM all_constraints WHERE wner = &&OWNER AND constraint_type = P ;
disPK sql
disPK sql To find out which primary keys are disabled / /SELECT owner constraint_name table_name status FROM all_constraints WHERE wner = &OWNER AND status = DISABLED AND constraint_type = P ;
nonuPK sql
nonuPK sql To find tables with nonunique PK indexes Requires that PK names follow a naming convention An alternative query follows that does not have this requirement but runs more slowly/ /
SELECT index_name table_name uniqueness FROM all_indexes WHERE index_name like &PKNAME% AND wner = &OWNER AND uniqueness = NONUNIQUE SELECT nstraint_name i tablespace_name i uniqueness FROM all_constraints c all_indexes i WHERE c owner = UPPER ( &OWNER ) AND i uniqueness = NONUNIQUE AND nstraint_type = P AND i index_name = nstraint_name
mkrebuild_idx sql
mkrebuild_idx sql Rebuild indexes to have correct storage parameters / /SELECT alter index || index_name || rebuild tablespace INDEXES storage || ( initial K next K pctincrease ) ; FROM all_indexes WHERE ( tablespace_name != INDEXES OR next_extent != ( ) ) AND wner = &OWNER /
datatype sql
datatype sql To check datatype consistency beeen o environments / /SELECT table_name column_name data_type data_length data_precision data_scale nullable FROM all_tab_columns first environment WHERE wner = &OWNER MINUS SELECT table_name column_name data_type data_length data_precision data_scale nullable FROM all_tab_columns@&my_db_link second environment WHERE wner = &OWNER order by table_name column_name
obj_coord sql
obj_coord sql To find out any difference in objects beeen o instances / / lishixinzhi/Article/program/Oracle/201311/17515
以上就是关于sql数据库删除的表通过那个工具能恢复吗全部的内容,包括:sql数据库删除的表通过那个工具能恢复吗、Oracle数据库管理员职责(四)、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)