Collections:
Creating Databases with Specified Physical Files in SQL Server
How to create database with physical files specified in SQL Server?
✍: FYIcenter.com
If you don't like the default behavior of the CREATE DATABASE statement, you can specify the physical database files with a longer statement:
CREATE DATABASE database_name
ON (NAME = logical_data_name,
FILENAME = physical_data_name,
SIZE = x, MAXSIZE = y, FILEGROWTH = z)
LOG ON (NAME = logical_log_name,
FILENAME = physical_log_name,
SIZE = x, MAXSIZE = y, FILEGROWTH = z)
For example, the following statement will create a database with database files located in the C:\temp directory:
USE master
GO
DROP DATABASE FyiCenterData
GO
CREATE DATABASE FyiCenterData
ON (NAME = FyiCenterData,
FILENAME = 'C:\temp\FyiCenterData.mdf',
SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = 5MB)
LOG ON (NAME = FyiCenterLog,
FILENAME = 'C:\temp\FyiCenterLog.ldf',
SIZE = 1MB, MAXSIZE = 5MB, FILEGROWTH = 1MB)
GO
SELECT type_desc, name, physical_name, size
FROM sys.database_files
GO
type_desc name physical_name size
ROWS FyiCenterData C:\temp\FyiCenterData.mdf 1280
LOG FyiCenterLog C:\temp\FyiCenterLog.ldf 128
⇒ Renaming Database Names in SQL Server
⇐ Location of Database Files in SQL Server
2016-11-24, 2355🔥, 0💬
Popular Posts:
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL...