11 October - 17 October - Creating - and - Maintaining - Database
11 October - 17 October - Creating - and - Maintaining - Database
Database
By: SBD Team
What is a Database?
Tables
Views
Indexes
Stored Procedures
Triggers
Files
Primary
A database must consist of a primary data file and one
transaction log file.
Contain the database objects
Can be used for system tables and objects
The primary data file has a .mdf extension
Secondary
Databases need have secondary data files if the primary data
file is not large enough to hold all the data in the database.
Very large databases may need multiple secondary data files.
Can be used to store user data and objects
The secondary data file has a .ndf extension
Files
Transaction Log
Transaction log files hold the log information
used to recover the database.
There must be at least one transaction log
file for each database, although there may
be more than one.
The minimum size for a transaction log file
is 512 KB.
The log files have an extension of .ldf
Creating a Database
Creating a Database Defines:
The name of the database
The size of the database
The files where the database will reside
MaxSize
This parameter specifies the maximum size to which the file can
grow. You can specify sizes in megabytes—the default value—or
kilobytes.
If you do not specify a size, the file grows until the disk is full.
FileGrowth
OrdHist1.ndf
OrdHist1.ndf
Northwind.mdf
Northwind.mdf OrdHist2.ndf
OrdHist2.ndf Northwind.Idf
Northwind.Idf
Syntax:
sp_renamedb ‘old_Dbname’, ‘new_Dbname’
Example:
sp_renamedb ‘employee’,’emp’
Dropping a Database
Methods of Dropping a Database
SQL Server Enterprise Manager
DROP DATABASE statement
DROP
DROP DATABASE
DATABASE Northwind,
Northwind, pubs
pubs