Creation of databases: CREATE DATABASE Data_name
On primary
(
name=data_1,
F ilename= ' D\data\data_name.mdf ',
size=50MB,
maxsize=unlimited,
filegrowth=10%
)
Log on
(
name=data_2,
filename= ' d\data\data_name.ldf ',
size=30MB,
maxsize=unlimited,
filegrowth=2MB
)
Explain:
Create a database named Data_ name
The main file name is data_1, the storage location is the D disk under the data file Data_name.mdf, the file size is 50MB, the maximum is unlimited, growth rate of 10%
The log file name is data_2, the storage location is the D disk under the data file Data_name.ldf, the file size is 30MB, the maximum is unlimited, the growth rate of 2MB
Deletion of databases:drop Database Data_name
Modifications to the database:
Modify database name:exec sp_renamedb ' data_name_old ', ' data_name_new ';
Add a new data file to the database:alter database Data_name
Add File
(
name=new_file,
filename= ' d\data\new_file.mdf ',
size=10MB,
maxsize=unlimited,
filegrowth=10MB
)
Modify the file size in the database:
Increase data files and log files:ALTER DATABASE Data_name
Modify File
(
name=new_file,
size=100MB
)
Note: This method can only increase the size of the file, can not be reduced, or will error!
To narrow down the data and log files:
DBCC SHRINKFILE (file_name,30)
T-SQL database-Delete and change