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