C #----The creation of a database

Source: Internet
Author: User
Tags create database
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.