这是我以前做的一个网站项目中的开发文档附件。我后来的一段时间都是用PHP+MySQL数据库做网站,很久没接触SQL Server数据库了,但现在又要跟SQL Server数据库打交道了,就把这个附近发了出来,方便参考。

★附件㈠、如何进行SQL Server数据库的备份与恢复

  方法一、利用备份和恢复

  先对源数据库进行完全备份,备份到一个设备(device)上,然后把备份文件复制到目的服务器上(恢复的速度快),进行数据库的恢复操作,在恢复的数据库名中填上源数据库的名字(名字必须相同),选择强制型恢复(可以覆盖以前数据库的选项),在选择从设备中进行恢复,浏览时选中备份的文件就行了。这种方法可以完全恢复数据库,包括外键,主键,索引。

  方法二、直接拷贝数据文件

  把数据库的数据文件(*.mdf)和日志文件(*.ldf)都拷贝到目的服务器,在SQL Server Query Analyzer(中文名:SQL查询分析器)中用语句进行恢复:

EXEC sp_attach_db @dbname = 'test',
@filename1 = 'c:\mssql\data\test_data.mdf',
@filename2 = 'c:\mssql\data\test_log.ldf'

  这样就把test数据库附加到SQL Server中,可以照常使用。如果不想用原来的日志文件,可以用如下的命令:

EXEC sp_detach_db @dbname = 'test'
EXEC sp_attach_single_file_db @dbname = 'test',
@physname = 'c:\mssql\data\test_data.mdf'

  这个语句的作用是仅仅加载数据文件,日志文件可以由SQL Server数据库自动添加,但是原来的日志文件中记录的数据就丢失了。




技术大类 » Windows相关 | 评论(45) | 引用(0) | 阅读(36107)
shzz Email
2022-8-18 16:43
As a seller of legal steroids, you can buy Crazy Bulk products, explore stacks and finally get the body you’ve always wanted  Digital Real Estate Business
shz Email
2022-8-18 16:45
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers.  Digital Real Estate Business
shzz Email
2022-8-18 16:49
I quite like reading an article that can make people think. Also, thanks for allowing for me to comment!  Digital Real Estate Business
billie34 Email
2023-1-12 15:46
A popular relational database management solution is SQL Server. In many sizable businesses, word wipe it is employed for data storage and retrieval. Microsoft SQL Server advises users to regularly backup the database to guard against corruption or loss of data.word wipe
andreaa34 Email
2023-3-25 22:51
The SQL Server backup and restore component is retro bowl critical for safeguarding critical data stored in your SQL Server databases.
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]