SqlServer create a database in two ways

A SqlServer database instance can probably create more than 30,000 databases.

The first way to create the database: SqlServer Management Studio management tool for visual creation.

1), a database management tool to open, the "Object Explorer", the connection to the database instance SqlServer Engine, and then expand the instance.

 

2), right-click "Database" and then click "New Database"

 

3), in the "New Database", enter the database name (the other according to their specific needs, no matter where I direct the default) and click OK, you create a database.

 

 The second way to create a database - created using Transact-Sql:

1) connected to the database engine

2) on the top menu bar, click "New Query"

 

 3, enter the database creation statements, click "Run." This example creates a database called the BOOK. Use the keyword Primary, means that we create a master file (master file data is stored).

/ * * Create a database and specify mdf and ldf file storage database * * / 
the USE Master
 the GO 
the CREATE  DATABASE BOOK the ON  a PRIMARY 
( 
    NAME = ' book_data ' , - master file logical filename 
    FILENAME = ' D: \ MyLocalDB \ book_data.mdf ' , - the master file filename 
    sIZE = 5MB, - the system will default when creating the initial master file allocation size 
    MAXSIZE = 500MB, - the maximum master file 
    FILEGROWTH = 15 % - the growth rate of the primary file 
)
 LOG The ON 
( 
    name = ' book_log ' , - log file logical file name 
    filename = ' D: \ MyLocalDB \ book_log.ldf ' , - log file filename room 
    SIZE = 5MB, - log file initial size 
    FILEGROWTH = 0  - - start automatic growth 
)
 GO

Guess you like

Origin www.cnblogs.com/bigbosscyb/p/11821523.html