View SqlServer database, add data files

First, see a list of database instances SqlServer

All database 1), expand the following examples directly in SSMS (SqlServer Management Studio) management tool which can view

 

 2) using Transact-SQL View

Open SSMS management tool, click on the "New Search" on the menu bar, enter the following SQL statements can be executed at the click Back to results list to see

/ * * Query all databases * * / 
the USE Master
 GO 
the SELECT  *  the FROM the sys.databases;
 GO

Second, add data files and log files to the database

Each database can specify up to more than 30,000 documents and more than 30,000 files group

The first way, through visual database administration tools to add files, groups of files:

1) using SSMS in the "Object Explorer", the connection after a successful database, expand the "Database", right-click the database from which you want to add files, and then click "Properties."

 

 2), in the "Database Properties" dialog box, select "File" page.

 

 3) Click "Add" to add "database file", enter the logical name, select the line in the file; To add the "log file", enter the logical name, select the "log" type. (Note that the file name can not be repeated in the database)

 

 

 4) For data files, we can choose the file group files are located when you add or select "<new file group>" to create a new file group. (Note that the transaction log file group that is not on the log files do not file group).

 

By Transact-SQL add files, groups of files:

1), open SSMS, in the menu bar, click "New Query"

2) Enter the following SQL, and then click Execute. Add complete database file. (Note: The following data document file group .ndf suffix to distinguish the master file as .mdf.)

 

The ALTER  DATABASE Books
 the ADD  the FILE - added to the plurality of files in a file group 
( 
  NAME = ' book_data110 ' , 
  filename = ' D: \ MyLocalDB \ book_data1.ndf ' , 
  size = 7MB, 
  MAXSIZE = 200MB, 
  FILEGROWTH = 5MB 
), 
( 
    the Name = ' book_data121 ' , 
    filename = ' D: \ MyLocalDB \ book_data2.ndf ' , 
    SIZE =  8MB,
    the MAXSIZE =500MB,
    FILEGROWTH=3MB
)
TO FILEGROUP bookgroup1;
GO

 

 

Guess you like

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