MSSQL CREATE DATABASE
Check
To list existing databases...
SELECT name, database_id, create_date
FROM sys.databases ;
To check where they are on disk...
SELECT DB_NAME(mf.database_id) AS DB_NAME,
mf.name AS LOGICAL_NAME,
mf.type_desc AS File_Type,
mf.physical_name AS Physical_File_Location
FROM sys.master_files AS mf
ORDER BY mf.database_id, mf.type
SSMS Database Creation
If you know your database is expected to be 10GB in size, it may be better to set the initial size to 10240MB to avoid the overhead of file growth later.
For transaction logs, it's difficult to offer any rules of thumb for initial size. My recommendation is to take your best guess now and fix it later.
Next Steps
SQL-Based Database Creation
CREATE DATABASE [myDatabase]
SQL (Advanced)
CREATE DATABASE [myDB]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'MYDB',
FILENAME = N'E:\SQLData\myDB.mdf',
SIZE = 16384000KB ,
MAXSIZE = UNLIMITED,
FILEGROWTH = 102400KB )
LOG ON
( NAME = N'MYDB_log',
FILENAME = N'F:\SQLLogs\myDB_log.ldf' ,
SIZE = 19724992KB ,
MAXSIZE = 2048GB ,
FILEGROWTH = 102400KB )
GO
- ON specifies that disk files will be explicitly defined
- PRIMARY specifies that we are explicitly defining the primary file
- LOG ON specifies that we are explicity defining the log file(s)
- NAME is the logical name for the file. Must be unique in the database (but not the instance)
- SIZE is the initial size of the file. The default is the size of the primary file in the MODEL database. For secondary files the default is 8MB (SQL2016+) or 1MB (all earlier versions).
- MAXSIZE specifies a maximum file size. If it is UNLIMITED or is not explicitly set then fthe file will grow until the disk is full.
- FILEGROWTH defaults to 64MB for SQL2016+
Initial Configuration
ALTER DATABASE [myDB] SET COMPATIBILITY_LEVEL = 110
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [myDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [myDB] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [myDB] SET ANSI_NULLS OFF
GO
ALTER DATABASE [myDB] SET ANSI_PADDING OFF
GO
ALTER DATABASE [myDB] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [myDB] SET ARITHABORT OFF
GO
ALTER DATABASE [myDB] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [myDB] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [myDB] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [myDB] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [myDB] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [myDB] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [myDB] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [myDB] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [myDB] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [myDB] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [myDB] SET DISABLE_BROKER
GO
ALTER DATABASE [myDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [myDB] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [myDB] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [myDB] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [myDB] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [myDB] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [myDB] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [myDB] SET MULTI_USER
GO
ALTER DATABASE [myDB] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [myDB] SET DB_CHAINING OFF
GO
ALTER DATABASE [myDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [myDB] SET TARGET_RECOVERY_TIME = 0 SECONDS
GO
ALTER DATABASE [myDB] SET READ_WRITE
GO
ALTER DATABASE [myDB] SET RECOVERY FULL
GO
Next Actions
Duplicate Database
To existing empty database (created as above)