Create a primary database file and a log file
--point to the database that you are currently using use master go to
CREATE database Students
on Primary (
--The logical name
of the db file name = ' Studentmanagedb_data ',
--Database physical file name (absolute path)
filename = ' D:\SQL\DB\StudentManageDB_data.mdf ',
-- Database file Initial Size
= 10MB,
--Data file growth
filegrowth = 5MB
)
--Create log file logs on
(
name= ' Studentmanagedb_log ',
filename = ' D:\SQL\DB\StudentManageDB_log.ldf ',
size = 5MB,
filegrowth = 1MB
)
Go
Select all press F5 or press "execute icon"
See below command completed successfully
Find the directory under the letter has just created the database file, and log
Open the manager or refresh to have the database you just created.
Create multiple database files and log files
。 A database must, and can contain only one MDF, but can have multiple NDF and LDF files (at least one)
Delete Database
Delete method
Exists () statement: detects if a studentmanagedb database exists, deletes if present
The database will not be recoverable after drop deletion. Use to be cautious
All code: