sqlserver附加数据库(sqlserver附加数据库)
Remote desktop
Frequently-used:
1. mstsc /v: 192. 168. 0. 1
Used when the connection sqlcmd command:
Sqlcmd -S Server\Instance
Where Server is the name of the computer and Instance is the name of the instance.
After the 3. connection, type the following command:
USE [master]
GO
CREATE DATABASE [databas e_name] ON (FILENAME = N'C:\Program, Files\Microsoft, SQL,
Server\MSSQL10_50. MSSQLSERVER\MSSQL\Data\<database, name>. mdf'),
(FILENAME = N'C:\Program, Files\Microsoft, SQL, Server\MSSQL10_50. MSSQLSERVER\MSSQL\Data\<database, name>. Idf')
FOR ATTACH;
GO
Among them, database name is the name you want to attach the database, FileName is the path and file name of the database and log files, FOR and ATTACH are specified by attaching a set of existing operating system files to create database.
4. , to verify that the database is attached, type the following two commands:
Select name from
Go
The 5. sqlcmd tool displays the names of all databases attached to the SQL Server Express instance. In the list, you should see the database name provided in step 3.
-must first establish [DataBase] folder in the C drive under
USE Master
GO
Check that the test database exists, and if it exists, delete it
IF EXISTS (SELECT, NAME, FROM, SYSDATABASES, WHERE, NAME
='MyDB')
DROP DATABASE MyDB
GO
CREATE DATABASE MyDB
ON
一 data files
(
NAME = MyDB_dat,
FILENAME =' C:\DataBase\MyDB_dat. mdf' ,
SIZE = 10 一 defaults to MB
MAXSIZE = 50,
FILEGROWTH = 5
-log file 登录
(
名称二 mydb log,
文件名二“C: \ \ mydb_log LDF的数据库,
Imb大小=,
25mb MAXSIZE =,
增长速度为Imb
)
去
——数据库创建示例2
使用主
去
如果存在(选择的名字name = "mydb”中)
删除数据库文件
使用主
去
创建一个数据库
在
——主数据文件
(
名称二 mydb dat 1,
文件名="C: \ \ mydb dat 1 mdf数据库,
大小为10 MB,一默认值为
为二50,
增长速度为5
),
——次要数据文件
名称二 mydb_dat2,
文件名="c: \ \ mydb_dat2 NDF的数据库,
大小为10 MB,一默认值为
为=50,
增长速度为5
)
登录
——主日志
(
名称=mydb_logL
文件名="C: \ \ mydb_logl LDF的数据库,
Imb大小=,
25mb MAXSIZE =,
增长速度为Imb
),
次要日
sqlserver附加数据库sqlserver附加数据库 来自淘豆网www.taodocs.com转载请标明出处.