Bootstrap FreeKB - Microsoft SQL Server - create database using transact sql (mdf ldf)
Microsoft SQL Server - create database using transact sql (mdf ldf)

Updated:   |  Microsoft SQL Server articles

The create database command can be used to create a new database. In this example, a database named foo is created. Notice two files are created, foo.mdf (Main Data File) and foo.ldf (Log Data File). The Main Data File contains all of the information about the foo database and the Log Data File logs all transactions and changes made to the database.

CREATE DATABASE foo
ON
( NAME = foo_data,
    FILENAME = 'Z:\path\to\foo.mdf',
    SIZE = 10MB,
    MAXSIZE = 50MB,
    FILEGROWTH = 5MB )
LOG ON
( NAME = foo_log,
    FILENAME = 'Z:\path\to\foo.ldf',
    SIZE = 5MB,
    MAXSIZE = 25MB,
    FILEGROWTH = 5MB ) ;

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 4f6dc9 in the box below so that we can be sure you are a human.