📄 457.html
字号:
<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>论坛精华 >> SQL之家 >> 备份SQL数据库SQL语句语法</title>
</head>
<body >
<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>
<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=4>论坛精华</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=45&int_attribute=4>SQL之家</a>
>> 备份SQL数据库SQL语句语法 [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=457>查看别人的评论</a>]<br>
<hr><p>由 amtd 发布于: 2001-02-15 09:47</p><p><img src="images/icons/icon1.gif" alt="Post" border=0> </p><p><br><br>Caution Backups created with Microsoft&reg; SQL Server&#8482; version 7.0 cannot be restored in earlier versions of <br>SQL Server.<br><br><br>--------------------------------------------------------------------------------<br><br>Syntax<br>Backing up an entire database:<br><br>BACKUP DATABASE {database_name | @database_name_var}<br>TO <backup_device> [,...n]<br>[WITH <br> [BLOCKSIZE = {blocksize | @blocksize_variable}]<br> [[,] DESCRIPTION = {text | @text_variable}]<br> [[,] DIFFERENTIAL]<br> [[,] EXPIREDATE = {date | @date_var} <br> | RETAINDAYS = {days | @days_var}]<br> [[,] FORMAT | NOFORMAT]<br> [[,] {INIT | NOINIT}]<br> [[,] MEDIADESCRIPTION = {text | @text_variable}]<br> [[,] MEDIANAME = {media_name | @media_name_variable}]<br> [[,] [NAME = {backup_set_name | @backup_set_name_var}]<br> [[,] {NOSKIP | SKIP}]<br> [[,] {NOUNLOAD | UNLOAD}]<br> [[,] [RESTART]<br> [[,] STATS [= percentage]]<br>]<br><br>Backing up specific files or filegroups:<br><br>BACKUP DATABASE {database_name | @database_name_var}<br> <file_or_filegroup> [,...n]<br>TO <backup_device> [,...n]<br>[WITH<br> [BLOCKSIZE = {blocksize | @blocksize_variable}]<br> [[,] DESCRIPTION = {text | @text_variable}]<br> [[,] EXPIREDATE = {date | @date_var} <br> | RETAINDAYS = {days | @days_var}]<br> [[,] FORMAT | NOFORMAT]<br> [[,] {INIT | NOINIT}]<br> [[,] MEDIADESCRIPTION = {text | @text_variable}]<br> [[,] MEDIANAME = {media_name | @media_name_variable}]<br> [[,] [NAME = {backup_set_name | @backup_set_name_var}]<br> [[,] {NOSKIP | SKIP}]<br> [[,] {NOUNLOAD | UNLOAD}]<br> [[,] [RESTART]<br> [[,] STATS [= percentage]]<br>]<br><br>Backing up a transaction log:<br><br>BACKUP LOG {database_name | @database_name_var}<br>{<br> [WITH <br> { NO_LOG | TRUNCATE_ONLY }]<br>}<br>|<br>{<br> TO <backup_device> [,...n] <br> [WITH <br> [BLOCKSIZE = {blocksize | @blocksize_variable}]<br> [[,] DESCRIPTION = {text | @text_variable}]<br> [[,] EXPIREDATE = {date | @date_var} <br> | RETAINDAYS = {days | @days_var}]<br> [[,] FORMAT | NOFORMAT]<br> [[,] {INIT | NOINIT}]<br> [[,] MEDIADESCRIPTION = {text | @text_variable}]<br> [[,] MEDIANAME = {media_name | @media_name_variable}]<br> [[,] [NAME = {backup_set_name | @backup_set_name_var}]<br> [[,] NO_TRUNCATE]<br> [[,] {NOSKIP | SKIP}]<br> [[,] {NOUNLOAD | UNLOAD}]<br> [[,] [RESTART]<br> [[,] STATS [= percentage]]<br> ]<br>}<br><br><br><backup_device> ::=<br> {<br> {backup_device_name | @backup_device_name_var}<br> |<br> {DISK | TAPE | PIPE} =<br> {'temp_backup_device' | @temp_backup_device_var}<br> }<br><br><br><file_or_filegroup> ::=<br> {<br> FILE = {logical_file_name | @logical_file_name_var}<br> |<br> FILEGROUP = {logical_filegroup_name | @logical_filegroup_name_var}<br> }<br><br>Arguments<br>DATABASE <br>Specifies the complete backup of the database. If a list of files and filegroups is specified, only those <br>files and filegroups are backed up. <br>--------------------------------------------------------------------------------<br><br>Note During a full database or differential backup, SQL Server backs up enough of the transaction log to <br>produce a consistent database for when the database is restored. Only a full database backup can be <br>performed on the master database. <br><br><br>--------------------------------------------------------------------------------<br><br>{database_name | @database_name_var} <br>Is the database from which the transaction log, partial database, or complete database is being backed up. <br>If supplied as a variable (@database_name_var), this name can be specified either as a string constant <br>(@database_name_var = database name) or as a variable of character string data type, except for the ntext <br>or text data types. <br><backup_device> <br>Specifies the permanent or temporary backup device to use for the backup operation. Can be one or more of <br>the following: <br>{backup_device_name} | {@backup_device_name_var} <br>Is the logical name, which must follow the rules for identifiers, of the backup device(s) (created by <br>sp_addumpdevice) to which the database is backed up. If supplied as a variable (@backup_device_name_var), <br>the backup device name can be specified either as a string constant (@backup_device_name_var = backup <br>device name) or as a variable of character string data type, except for the ntext or text data types. <br>{ DISK | TAPE | PIPE } = <br>'temp_backup_device' | @temp_backup_device_var <br>Allows backups to be created on the named disk, tape, or pipe device. When using a temporary disk backup <br>device, the temporary disk backup devices must not exist prior to specifying the BACKUP statement. When <br>using a tape backup device, specify WITH FORMAT to ensure that the backup device is a valid Microsoft Tape <br>Format (MTF) data set. <br><br><br>--------------------------------------------------------------------------------<br><br>Important Use FORMAT carefully because it overwrites all contents on the current tape. <br><br><br>--------------------------------------------------------------------------------<br><br>With disk and tape, specify the complete path and file name. For example, DISK = ‘C:\Mssql7<br>\Backup\Mybackup.dat’ or TAPE = \\.\TAPE0. With pipe, specify the name of the named pipe that will be <br>used by the client application. If supplied as a variable (@temp_backup_name_var), the temporary backup <br>device name can be specified as a string constant or as a variable of character string data type, except <br>for the ntext or text data types. <br><br>Pipe files have been added to allow third-party vendors a flexible and powerful way to connect their own <br>software. For typical Transact-SQL use, pipe files are not used. <br><br><br>--------------------------------------------------------------------------------<br><br>Note When performing a backup to a named pipe, you may need to adjust the number of minutes that SQL <br>Server waits for the client to connect before reporting a failure. To adjust this time-out interval from <br>the default of 2 minutes, create the BackupNamedPipeConnectTimeout registry key and add the following <br>registry value: <br><br>HKEY_LOCAL_MACHINE<br>\SOFTWARE<br> \Microsoft<br> \MSSQLServer<br><br>Data Type: REG_DWORD<br>Data: Value other than the default of 2<br>Radix: Decimal <br><br><br>--------------------------------------------------------------------------------<br><br>--------------------------------------------------------------------------------<br><br>If you are using a network server with a UNC name or using a redirected drive letter, specify a device <br>type of disk. <br><br><br>--------------------------------------------------------------------------------<br><br>Important When specifying multiple files, logical file names (or variables) and temporary file names (or <br>variables) can be mixed. However, all devices must be of the same type (disk, tape, or pipe). <br><br><br>--------------------------------------------------------------------------------<br><br>n <br>Is a placeholder indicating that multiple backup devices may be specified. The maximum number of backup <br>devices is 32. <br>BLOCKSIZE = {blocksize | @blocksize_variable} <br>Specifies the physical block size, in bytes. <br>For DISK, BACKUP automatically determines the appropriate block size for disk devices. <br><br><br>--------------------------------------------------------------------------------<br><br>Note If you intend to transfer the resulting backup set to a CD-ROM and then restore from that CD-ROM, you <br>must set BLOCKSIZE to 2048. <br><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -