1. createdatabasedataname this is the easiest way to create a database. all attributes of the database are default. such as database files and log file storage directories. database size. the following describes the clauses that often determine database attributes. on: defines the location of the stored database file. See the following code. filename: Database Logic
1. create database dataname this is the easiest way to create a database. all attributes of the database are default. such as database files and log file storage directories. database size. the following describes the clauses that often determine database attributes. on: defines the location of the stored database file. See the following code. filename: Database Logic
1. create database dataname
This is the easiest way to create a database. All attributes of the database are default, such as the database file and log file storage directory and database size.
The following describes the clauses that often determine database attributes.
- On: defines the location of the stored database file. See the following code.
- Filename: Logical alias of the database
- Size: initial database size
- Maxsize: the initial capacity of the database.
- Filegrowth: the size of the database added each time.
- Log on: defines the location for storing database log files.
Check the creation code:
- Create database Accounting
- On (name = 'accountingname ',
- Filename = 'f:/Summary/SQL/create and modify a data table/Accounting. mbdf ',
- Size = 10 mb,
- Maxsize = 50 mb,
- Filegrowth = 5 mb)
- Log on (name = 'accountinglog ',
- Filename = 'f:/Summary/SQL/create and modify a data table/Accounting. log ',
- Size = 10 mb,
- Maxsize = 50 mb,
- Filegrowth = 5 mb)
As mentioned above, filegrowth: the size of the database increases every time combined with the code. the initial database size is 10 MB. when the database capacity exceeds. it automatically increases by 5 MB. this will be the size of 15 MB. up to 50 mb
Create database song on
(Name = ktvdata, filename = 'd:/database/ktvdata. mdf ',
Size = 8 MB, maxsize = 9 MB, filegrowth = 100KB)
Log on
(Name = ktvdata_log, filename = 'd:/database/ktvdata. ldf ',
Size = 9 MB, maxsize = 10 MB, filegrowth = 100KB)
Go
2. Use the alter database statement to modify the DATABASE
Example 4-3 add two data files and one transaction log file to the test database.
The program list is as follows:
Alter database Test
ADD FILE
(NAME = Test1, FILENAME = 'C:/Program Files/Microsoft SQL Server/MSSQL/Data/test1.ndf ', SIZE =
5 MB, MAXSIZE = 100 MB, FILEGROWTH = 5 MB ),
(NAME = Test2, FILENAME = 'C:/Program Files/Microsoft SQL Server/MSSQL/Data/test2.ndf ', SIZE =
3 MB, MAXSIZE = 10 MB, FILEGROWTH = 1 MB)
GO
Alter database Test
Add log file (NAME = testlog1, FILENAME = 'C:/Program Files/Microsoft SQL
Server/MSSQL/Data/testlog1.ldf ', SIZE = 5 MB, MAXSIZE = 100 MB, FILEGROWTH = 5 MB)
GO
3. Rename test as demo.
Sp_renamedb 'test', 'Demo'
4. delete a database: drop database song
Go