3 types of databases
1.System databases
2.user defined
3.Sample databases
1System databases
At the time of installation 5 system databases are installed
1.Master
2.Model
3.Msdb
4.Temp db
5.Resource DB
Dbcc showfilestats
Total extents-used extents*64=free space in data file
Types of pages:
1. Data page: it consists of actual data default size is 8kb
2. Index allocation map(IAM) page: it consists of page no s which are
allocated to a table or index
3. index page: it consists of index entries ie column name & row reference
4. Differential change map(DCM) page : it consists of information of
extents modified after backup command.
5 .bulk changed map (BCM) page : it consists of information of extents
modified after bulk operation
6.page free space: It consists of page no & free spaces
7.Text & image page: it consists of information of text ,image .can contain
2gb data
Transactional Log file (.Ldf): it consists of both committed & uncommitted transactions
Once check points occurs all the committed transactions are taken into data
file.
Every transactions is recorded with unique no called LSN (Log sequence no)
Max size 2TB
To view the percent of log used
Dbcc sqlperf(logspace)
Or using DMV
Select *from sys.dm_db_log_space_usage
The main advantage is to recover data point of failure
Implementing log shipping , transactional replication.
VLF types
1.Active vlf : it is at least one transaction which should be delivered to some
other server
2.Recoverble: if the transaction are delivered from active vlf to other server
like mirror or distributor then its become recoverable
3.Reusable vlf:once t-log backup was generated or check point occurs in
simple recovery model recoverable vlf is truncated and becomes reusable vlf.
4.unused : never used
To check vlfs we can use
Dbcc loginfo
Select * from sys.databases
Sp_helpdb
Database states:
1.Online : allows manipulations selections ets .always production
db in online state
2.Offline: for moving data files
3.Restoring : when restoring database .in mirroring mirror server
should be in restoring mode .
4.Suspect mode: If the file of the data base is damaged or
corrupted .
If more than 100 pages are corrupted or when
restoration failed
5.Standby: DB is available in read only mode . In log shipping
secondary server in standby mode
To find state of database
Select name , state_desc from sys.databases
Select databaseproperyex(databasename,status)
How to resolve
Add extra data file if possible
Verify long running quires and stop
Dbcc opentran(tempdb)
Find out which sessions taking more space and trouble shoot the quiries
Select * from sys.dm_db_session_space_usage .
Try to shrink the log file
Dbcc shrinkfile(tempdb,0)
Restart the server if possible.
2.My transaction log file is full .how to troubleshoot the scenario?
Ans. If there is no scheduled log backups or log backups are not working .
If there are active transactions in the log file .
If there are long running queries .
In data base mirroring mirror server fails .
In replication if distribution server fails.
Trouble shooting:
Select name,log_reuse_wait_desk from sys.databases where
name=databasename
Depending on 2nd value we have to trouble shoot by using the following
solution
Backup the log
Adding log file to a different disk .
Trouble shoot if any mirroring or replication issues.