上的指定位置创建对采用T SQL数据库

如何对采用T SQL脚本上的指定位置创建一个数据库? 比方说,我想创建D上一个SQL Server数据库:\ TEMP \ dbFolder。 如何做到这一点?

--------------解决方案-------------

当您创建新的数据库您指定的位置。 例如:

USE [master]
GO

CREATE DATABASE [AdventureWorks] ON PRIMARY
( NAME = N'AdventureWorks_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf' , SIZE = 167872KB , MAXSIZE = UNLIMITED, FILEGROWTH = 16384KB )
LOG ON
( NAME = N'AdventureWorks_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Log.ldf' , SIZE = 2048KB , MAXSIZE = 2048GB , FILEGROWTH = 16384KB )
GO

从SQL Server丛书,其中数据库文件名,也明确地定义了一个例子:

USE master
GO
CREATE DATABASE Sales
ON
( NAME = Sales_dat,
FILENAME = 'c:\program files\microsoft sql server\mssql\data\saledat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Sales_log',
FILENAME = 'c:\program files\microsoft sql server\mssql\data\salelog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO

  1. 你的文件系统上创建文件夹:D:\ TEMP \ dbFolder \
  2. 运行该脚本:

    USE master;
    GO
    CREATE DATABASE TestDB1
    ON ( NAME = Sales_dat, FILENAME = 'D:\temp\dbFolder\TestDB1.mdf')
    LOG ON ( NAME = Sales_log, FILENAME = 'D:\temp\dbFolder\TestDB1.ldf');
    GO

请参阅此链接:CREATE DATABASE(Transact-SQL中)

CREATE DATABASE [ADestinyDb] CONTAINMENT = NONE ON PRIMARY
( NAME = N'ADestinyDb',
FILENAME = N'D:\temp\dbFolder\ADestinyDb.mdf' ,
SIZE = 3136 KB , MAXSIZE = UNLIMITED,
FILEGROWTH = 1024 KB )
LOG ON
( NAME = N'ADestinyDb_log',
FILENAME = N'D:\temp\dbFolder\_log.ldf' ,
SIZE = 832KB , MAXSIZE = 2048 GB , FILEGROWTH = 10 %)

你的文件系统上创建文件夹:D:\ TEMP \ dbFolder \,并运行以下脚本(用'山'登录)

USE master
CREATE DATABASE [faltu] ON PRIMARY
( NAME = N'faltu', FILENAME = N'D:\temp\dbFolder\faltu.mdf' , SIZE = 2048KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'faltu_log', FILENAME = N'D:\temp\dbFolder\faltu_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)

分类:TSQL 时间:2015-03-16 人气:9
本文关键词: TSQL
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.299 (s). 11 q(s)