SQL Server Database Creation

Source: Internet
Author: User
Tags filegroup

1. Create a database with a primary database file, a database filegroup, a primary log, and a secondary log file in the SQL language

2. Querying the database you just created using the SQL language

3. Add a filegroup to the database you just created in SQL language

----------------------------------If there is a database with the same name, delete the database use Masterif EXISTS (SELECT * from sysdatabases WHERE name= ' Market ') DROP database Marketgo----------------------------------Create databases-------------------------------- Marketon primary--PRIMARY filegroup (name= ' market_data.mdf ', filename= ' D:\SQLProject\Market_data.mdf ', size=5mb,filegrowth=10%, MAXSIZE=100MB), FILEGROUP fg--filegroup (name= ' fg_market.ndf ', filename= ' D:\SQLProject\Market_data.ndf ', SIZE=10MB, FILEGROWTH=10%,MAXSIZE=100MB) Log on--logs (name= ' market_log.ldf ', filename= ' D:\SQLProject\Market_log.ldf ', SIZE=2MB, filegrowth=0), (name= ' market2_log.ldf ', filename= ' D:\SQLProject\Market2_log.ldf ', size=5mb,filegrowth=0) GO------------------------------------------------------------------------Set default file group alter DATABASE Marketmodify FILEGROUP FG defaultgo------------------------------------------------------------------------Query all databases select * FROM Sysdatabasesgo------------------------------------------------------------------------make local modifications to the database--Add a filegroup use Marketalter DATAbase market Add FILEGROUP fg2goalter DATABASE Market Add FILE (name= ' fg2_market_data.ndf ', filename= ' D:\SQLProject\FG2_ Market_data.ndf ', SIZE=10MB,FILEGROWTH=10%,MAXSIZE=100MB) to FILEGROUP Fg2go------------------------------------

Operation Run Result:





SQL Server Database Creation

Related Article

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.