of 30 /30
1 SQL SERVER DBA – TOPIC WISE FAQs SQL SERVER 1) What is SQL Server ? Micr osoft SQL Ser ver 200 5 is a dat aba se platform for lar ge-s cal e onl ine transact io n pr oces si ng (OL TP ! data "are#o$ si ng ! an d e-commerce applications% it is also a b$siness intelligence platform for data integration! anal&sis! and reporting sol$tions' 2) What is t he V ersios A vai!a"!e i S QL Server? SQL Server "as developed b& Microsoft in 1)* and t#e versions are +'0! +'5! *'0! )'0(2000! '0(2005! 10(200)' #) What is th e Di $ere%e "et&ee SQL Server 2''' a( 2''?  SQL Server*2''' SQL Server*2''  T -SQL T -SQL as "ell as ,L .nterprise manager SSMS Q$er& /nal&er Q$er& editor TS SSS 3o eporting T ools SSS 3o .4ception #andling in TS .4ception #andling in SSS ,an create $p to 1+ nstances ,an create $p to 50 instances 3o e4ception #andling in TS' .4ception #andlin g in SSS' sa6 blan7 pass"ord' .nforce pass"ord polic&' 3o database mirroring atabase mirroring' Ob8ect oriented programming ,ommon lang$age r$ntime +) What are the E(itios av ai!a"!e ,or S QL Server 2 ''?  T#ere are + si4 editio ns available in SQL Server 2005 a .nt erprise .di ti on b Standard .di tio n ceveloper edition d 9or7 gr o$p edition e Mobile edition f .4press edition ) What are the T oo!s are avai!a"!e i SQL Server 2''' a( 2''? S! 2''' 2'' 1 .nterprise manager : Q$er& /nal&er Management St$dio 2 3et"or7 ,lient ;tilities ,on<g$ration manager = SQL Pro<ler Pro<ler > Service manager S$rface area con<g$ration 5 eporting Services ,on<g$ration + atabase T $ning /dvisor * ,ommand Prompt ;tilities

DBA Iq Faq-praveen

Embed Size (px)

Text of DBA Iq Faq-praveen

SQL SERVER 1) What is SQL Server?
Microsoft SQL Server 2005 is a database platform for large-scale online transaction processing (OLTP ! data "are#o$sing! and e-commerce applications% it is also a b$siness intelligence platform for data integration! anal&sis! and reporting sol$tions'
2) What is the Versio s Avai!a"!e i SQL Server? SQL Server "as developed b& Microsoft in 1 )* and t#e versions are +'0! +'5! *'0! )'0(2000 ! '0(2005 ! 10(200) '
#) What is the Di$ere %e "et&ee SQL Server 2''' a ( 2'' ?
SQL Server*2''' SQL Server*2'' T-SQL T-SQL as "ell as ,L .nterprise manager SSMS Q$er& /nal& er Q$er& editor
TS SS S 3o eporting Tools SS S 3o .4ception #andling in TS .4ception #andling in SS S ,an create $p to 1+ nstances ,an create $p to 50 instances 3o e4ception #andling in TS' .4ception #andling in SS S'
sa6 blan7 pass"ord' .nforce pass"ord polic&' 3o database mirroring atabase mirroring'
Ob8ect oriented programming ,ommon lang$age r$ntime
+) What are the E(itio s avai!a"!e ,or SQL Server 2'' ? T#ere are + si4 editions available in SQL Server 2005 a .nterprise .dition b Standard .dition c eveloper edition d 9or7gro$p edition e Mobile edition
f .4press edition
) What are the Too!s are avai!a"!e i SQL Server 2''' a ( 2'' ? S! 2''' 2'' 1 .nterprise manager : Q$er&
/nal& er Management St$dio
2 3et"or7 ,lient ;tilities ,on<g$ration manager = SQL Pro<ler Pro<ler > Service manager S$rface area con<g$ration 5 eporting Services
,on<g$ration + atabase T$ning /dvisor * ,ommand Prompt ;tilities
8/20/2019 DBA Iq Faq-praveen
-) What are Servi%es avai!a"!e i SQL Server? T#ere are t#ree services available in SQL Server 2005' a SQL server servi%e ?- t is responsible for r$nning atabases! S&stem
Stored Proced$res! S&stem nde4es! ;ser Login information and Pass"ords b SQL server a.e t servi%e ?- t is responsible for r$nning @obs! /lerts!
3otif&ing t#e operators c Distri"/te( Tra sa%tio Coor(i ator ?- t is responsible for moving data
among instances (One A to anot#er A
0) o& a 3 &a3s to r/ servi%es? Services are r$n b& 5 "a&s t#e& are 1) /t tas7 pane B ig#t clic7 on server and clic7 start C stop 2) Management St$dio B ig#t clic7 on Server and clic7 start C stop C restart 3) S$rface /rea ,on<g$ration 4) ,ommand Prompt B Net start/stop mssqlserver 5) SQL Server con<g$ration manager B ig#t clic7 on server and clic7 start C
stop C restart'
4) What is Wi (o&s A/the ti%atio ? 9#en 9indo"s a$t#entication is $sed to connect SQL Server! Microsoft 9indo"s is completel& responsible for a$t#enticating t#e client b& identif&ing its "indo"s $ser acco$nt'
5) What is SQL Server A/the ti%atio ?
9#en SQL Server a$t#entication is $sed! SQL Server a$t#enticates t#e clientb& comparing $ser name and pass"ord "it# $ser names and pass"ords maintained "it#in SQL Server'
1') What is the (i$ere %e "et&ee Wi (o&s A/the ti%atio a ( SQL Server a/the ti%atio ? 1 9indo"s a$t#entication is #ig#l& sec$re t#an SQL Server a$t#entication
"#& beca$se "e need not provide an& login details' So t#e c#ance of tracing login details from code b& t#e $na$t#ori ed persons "ill be less' 9indo"s a$t#entication $ses t#e defa$lt "indo"s login credentials'
2 9indo"s a$t#entication "ill $ses t#e credentials of t#e c$rrentl& logged $ser to login in to t#e SQL Server database' Do$r application need not to s$ppl& t#e $ser name and pass"ord'
= Eor SQL Server a$t#entication "e #ave to s$ppl& t#e SQL database $ser name and pass"ord' T#at "ill be $sed to get t#e privileges and rig#t of t#e $ser'
11) What is AWE? o& %o 6./re D3 a i% 7e or3 A!!o%atio ? Fenerall& SQL Server reserves onl& a small portion of memor&' Sometimes reserved memor& is not s$Gcient to SQL server and reH$ired additional memor&' AWE is /se( to s/88ort ver3 !ar.e a o/ ts o, 8h3si%a!
e or39 Whe AWE is e a"!e( the o8erati . s3ste (3 a i%a!!3a!!o%ates e or3 to SQL Server "ase( o the Min server memory
8/20/2019 DBA Iq Faq-praveen
a ( max server memory setti .s9 :1) Wi 9 Server 2''# SE s/88orts /t8o +;B :2) EE /8to #2;B9 :#) DC /8to -+;B) To Co 6./re AWE<* Ri.ht %!i%= o i sta %e > Pro8erties > 7e or3 > E a"!e AWE > Set 7i a ( 7a e or3 et%9 @ote ?- /9. is not needed and cannot be con<g$red on +>-bit operating s&stems'
12) What is Li =e( Server? o& to %o e%t Li =e( server? o& to test !i =e( Server?
One server connected "it# anot#er server to e4ec$te H$eries against OL. A data so$rces on remote servers' OLEDB Provi(er ?- /n OLE DB provider is a LL t#at manages and interacts "it# a speci<c data so$rces s$c# as SQL Server *'0! /ccess! .4cel! O A,! Oracle! A2! Local <le s&stem! .4c#ange Server etc' SQL 3ative ,lient (P OF ? SQL3,L is t#e oGcial OL. A provider for SQL Server'
To %o e%t !i =e( server /si . OLE DB 8rovi(er ?-spIaddlin7edserver JserverK6servername6! Jsrvprod$ctK6SQL ServerCOracle6 Tests the %o e%tio to a !i =e( server ?- spItestlin7edserver servernameB
1#) What is 8/r8ose o, Re.istere( Servers? egistering a server to store t#e server connection information for f$t$re
1+) What (o 3o/ ea "3 Co!!atio ?
,ollation is basicall& t#e sort order' T#ere are t#ree t&pes of sort orders (1 ictionar& case sensitive ! (2 ictionar& case insensitive! (= Ainar&
1 ) What are the Proto%o!s /se( i @et&or=i .? What is the De,a/!t Port / "er o, TCP IP?
T#e protocols $sed in net"or7ing are T,PC P! 3/M. P PP.S! /! SN/ . M.MO D' T#e defa$lt port no of T,PC P is 1>=='
1-) What is the S3 ta /se( ,or 6 ( the SQL Server versio ? 1 Select JJversion 2 ,lic7 on Server B S$mmar& eports B Server as#board B con<g$ration
details B See prod$ct version'
10) What is "!o%=i .? o& to i(e ti,3 a ( reso!ve the "!o%=i .s? Aloc7ing #appens "#en one $ser #olds an e4cl$sive loc7 on an ob8ect and a second $ser reH$ires an e4cl$sive loc7 on t#e same ob8ect' T#is forces t#e second $ser to "ait! bloc7 on t#e <rst' Deter i e B!o%=i . sessio s ?- /ctivit& Monitor! spI"#o2! spIloc7! s&s's&sprocess! s&s'dmIe4ecIreH$ests! s&s'dmIosI"aitingItas7s Reso!ve B!o%=i . Sessio ?- (1 ig#t clic7 on session and ill in /ctivit&
Monitor (2 Kill Session_id 14) What is Dea(!o%=?
8/20/2019 DBA Iq Faq-praveen
/ deadloc7 occ$rs "#en $sers tr& to place e4cl$sive loc7s on eac# ot#er6s ob8ects' E ?- ;ser1 places an e4cl$sive loc7 on Table1 and t#en tries to place an e4cl$sive loc7 on Table2' ;ser2 alread& #as an e4cl$sive loc7 on table2! and ;ser2 tries to p$t an e4cl$sive loc7 on Table1' T#is condition ca$ses endless loop of "aiting for t#e loc7s to be released' T#e atabase engine pic7s one of t#e victim ($sers and 7ills t#eir H$er& and send a error message to $sers Do$ are t#e victim of a deadloc7 and tr& again later ' Dea(!o%= I ,or atio Too!s 1 Tra%e F!a.s ?- A,, T /,.O3 (120> : A,, T /,.O3 (1222 ' 9#en
t#ese trace Rags is enabling! t#e deadloc7 information capt$red b& t#e SQL Server error log'
2 Dea(!o%= .ra8h eve t i SQL Pro6!er ?- SQL Server Pro<ler grap#icall& representation of tas7s and reso$rces involved in a deadloc7'
(Loc7? eadloc7 and Loc7? eadloc7 c#ain events in t#e Loc7s events= S3ste Vie& ?- 9e can <nd t#e bloc7ing sessions b& "riting t#e follo"ing H$er& Sele t session_id! stat"s! #lo $in%_session_id &rom s's(dm_e e _req"ests *+ere #lo $in%_session_id , -
Reso!vi . Dea(!o%= ?- /fter <nd t#e session ca$sing t#e problem "e can $se LL command' B LL processIid
15) What are the T38es o, Lo%=s? E 8!ai ea%h? T#ere are * loc7s t&pes are available in SQL Server 2005'
a Share( Lo%= ?- S#ared (S loc7s allo" conc$rrent transactions to read (S.L.,T a reso$rce $nder pessimistic conc$rrenc& control'
b 8(ate Lo%=< - ;sed on reso$rces t#at can be $pdated' Prevents a common form of deadloc7 t#at occ$rs "#en m$ltiple sessions are reading! loc7ing! and potentiall& $pdating reso$rces later'
c E %!/sive Lo%=< - .4cl$sive ( loc7s prevent access to a reso$rce b& conc$rrent transactions
d I te t Lo%=< - ;sed to establis# a loc7 #ierarc#&' T#e t&pes of intent loc7s are? intent s#ared ( S ! intent e4cl$sive ( ! and s#ared "it# intent e4cl$sive (S '
e S%he a< - ;sed "#en an operation dependent on t#e sc#ema of a table is e4ec$ting'
f B/!= 8(ate ?- ;sed "#en b$l7 cop&ing data into a table and t#e TABLOC #int is speci<ed
g e3*Ra .e ?- Protects t#e range of ro"s read b& a H$er& "#en $sing t#e seriali able transaction isolation level
2') What are the Co 8o e ts %a "e i sta!!e( &ith SQL Server 2'' ?
9e can install t#e follo"ing components "it# Microsoft SQL Server 2005 a SQL Server atabase .ngine
b /nal&sis Servicesc eporting Services d 3oti<cation Services
8/20/2019 DBA Iq Faq-praveen
e ntegration Services f Management Tools g oc$mentation and Samples
21) What are the SQL Server E(itio s o, SQL Server 2'' ? SQL Server 2005 is available in =2-bit and +>-bit editions' a SQL Server 2005 .nterprise .dition (=2-bit and +>-bit b SQL Server 2005 .val$ation .dition (=2-bit and +>-bit c SQL Server 2005 Standard .dition (=2-bit and +>-bit d SQL Server 2005 9or7gro$p .dition (=2-bit onl& e SQL Server 2005 eveloper .dition (=2-bit and +>-bit f SQL Server 2005 .4press .dition (=2-bit onl&
g SQL Server 2005 ,ompact .dition (=2-bit onl&# SQL Server 2005 $ntime .dition (=2-bit and +>-bit
22) What is the 8ro%ess o, I sta!!atio ? a Pre8are o/r Co 8/ter to I sta!! SQL Server 2'' <* To prepare &o$r
comp$ter for SQL Server 2005! revie" #ard"are and soft"are reH$irements! S&stem ,on<g$ration ,#ec7er reH$irements and bloc7ing iss$es! and sec$rit& considerations'
b I sta!! SQL Server 2'' <* To install SQL Server 2005! r$n Set$p $sing t#e SQL Server 2005 nstallation 9i ard or install from t#e command prompt' Do$ can also add components to an instance of SQL Server 2005!
or $pgrade to SQL Server 2005 from a previo$s SQL Server version' c Co 6./re o/r SQL Server 2'' I sta!!atio <* /fter Set$p completes
t#e installation of SQL Server 2005! &o$ can con<g$re SQL Server $sing grap#ical and command prompt $tilities
2#) What is the Virt/a! 7e or3? o& to assi. virt/a! e or3 ho& /%h s8a%e re /ire( ,or Virt/a! e or3? / reserved dis7 space to maintain transactions "#enever Memor& ( /M is f$ll' irt$al memor& si e is at least = times of t#e p#&sical memor& installed in t#e comp$ter' To Set Virt/a! e or3 ?- ig#t clic7 on S&stem B Select S&stem Properties B /dvanced B Performance Settings B /dvanced B irt$al memor& B ,#ange B Select director& B Provide min and ma4 val$es'
DATABASE 1) What is Data"ase? What are the 6!es %reate( &hi!e %reati . a
Data"ase? / atabase is a collection of meaningf$l and related data t#at are stored in ro" and col$mns format (Tables ' 9#ile creating a atabase in SQL Server t#ere are t"o data <les are created called master data <le ('mdf ! log data <le ('ldf and
"e can add one or more optional 3- imensional data <les ('ndf ' 2) E 8!ai a"o/t Data 6!es :9 (,G 9 (,G 9!(,) :Fi!e str/%t/re)?
8/20/2019 DBA Iq Faq-praveen
a Pri ar3 Data 6!e :9!(,) ?- Primar& data <les #olds $ser data and ob8ects' .ver& database #as one primar& data <le'
b Se%o (ar3 Data 6!e :9 (,) ?- Secondar& ata <le ('ndf is optional and #old $ser data and ob8ects t#at do not <t in t#e Primar& data <le' 9e can add 3 no' of Secondar& data <les for a A'
c Lo. Data 6!e :9!(,) ?- T'Log records all t#e transactions and database modi<cations made b& eac# transaction and it is $sed to recover t#e database' /t least one transaction log <le reH$ired for eac# A' Min' log <le si e is 512 A'
#) o& store the (ata i SQL Server? What is Pa.e a ( Pa.e siHe? What is E te t a ( E te t siHe?
T#e f$ndamental $nit of data storage in SQL server is t#e . 0E ' T#e si e of t#e page is ) 7b' ,ollection of eig#t contig$o$s pages is 7no"n as an E EN ' T#e si e of an e4tent is +> 7b ()4) '
+) What is Fi!! ,a%tor? o& to assi. Fi!! ,a%tor?/ Eill factor is a reserved free space on eac# leaf level page "#ic# is $sed for f$t$re gro"t# of data or inde4 in a table and red$ces t#e page splits' Assi. Fi!! Fa%tor ?- ig#t ,lic7 on Server B Properties B atabase Settings B
efa$lt nde4 Eill Eactor B Provide t#e val$e
) Te!! e a"o/t S3ste Data"ase a ( ser Data"ases i 2''' a ( 2'' ? SQL Server 2''' ?- 1 Master 2 Model = MS A > Temp A SQL Server 2'' ?- 1 Master 2 Model = MS A > Temp A 5 eso$rce A
-) E 8!ai a"o/t S3ste Data"ases i SQL Server 2'' ?
T#ere are <ve s&stem databases available in SQL Server 2005' a 7aster Data"ase ?- ecords Server level ob8ects s$c# as Login /cco$nts! .nd
Points! Lin7ed Servers! S&stem ,on<g$ration settings! location of t#e database <les and initiali ation information for SQL server' SQL Server ,annot starts if Master A is $navailable'
b 7o(e! Data"as e?- T#e Model A is $sed as a template for all databases created on instances of SQL Server' f "e create a ne" atabase t#e Model
A str$ct$re "ill be in#erited to ne" atabase' c 7SDB Data"ase ?- T#e msdb database is $sed b& SQL Server /gent for
sc#ed$ling alerts and 8obs and b& ot#er feat$res s$c# as Service Aro7er and atabase Mail' SQL Server a$tomaticall& maintain completed online bac7$p
and restore #istor& in MS A' d Te 8DB ?- Temp A is a global reso$rce A' t stores $ser ob8ects (global or
local temporar& tables! stored proced$res! table variables! or c$rsors ! nternal ob8ects (intermediate res$lts for spools or sorting and versions
(online inde4 operations! M$ltiple /ctive es$lt Sets (M/ S ! and /ET. triggers ' 9e cannot bac7$p t#e Temp A beca$se "#en SQL Server Start (or Stop t#e Temp A can be deleted permanentl& (or refres# Temp A'
e Reso/r%e Data"ase ?- T#e eso$rce database is a #idden (read-onl& database t#at contains all t#e s&stem ob8ects s$c# as s&s'ob8ects t#at are incl$ded "it# SQL Server 2005' T#e eso$rce database ma7es $pgrading
process easier and faster'
8/20/2019 DBA Iq Faq-praveen
0) I, 7o(e! a ( 7SDB Data"ase &i!! %rash &hat 3o/ &i!! (o? o& to re"/i!( 7aster Data"ase?
9e can re-create Model and MS A databases b& reb$ild t#e Master atabase'
SQL Server 2''' :Re"/i!( 7asterDB) ?- Start B $n B rebuildm.exe SQL Server 2'' :Re"/i!( 7asterDB) ?- Start B $n B setup.exe
4) o& to ove 7o(e!G 7SDBG Te 8DB? a' ,#ec7 t#e Pat# of Temp A t#ro$g# spINelp A Temp A b' /LT. /T/A/S. tempdb MO ED E L. (3/M. K tempdev! E L.3/M. K
.?Utempdb'mdf % c' Stop t#e Services d' Move t#e <les to desired location e' estart t#e Services f' ,#ec7 t#e Pat# of Temp A t#ro$g# spINelp A Temp A
5) o& to ove 7aster Data"ase? a' ,#ec7 t#e Pat# of Master A t#ro$g# spINelp A Master b' Stop t#e Services c' ,#ange t#e pat# at Start$p parameters
SQL Server ,on<g$ration manager B Services B ig#t clic7 on Service B Properties B /dvanced B /dd ne"Ipat# at Start$p parameters
d' Move t#e <les to desired location e' estart t#e Services f' ,#ec7 t#e Pat# of Master A t#ro$g# spINelp A Master
1') What are the Data"ase States a ( e 8!ai the ? T#e main database states are online! oVine! restoring! recovering! reso$rce pending! s$spect and emergenc&'
11) What is Data"ase S a8shot? ;ive the S3 ta ? / atabase snaps#ot is a read-onl& static vie" of t#e database' Snaps#ots m$st be located on t#e same server' Snaps#ots doesn6t contain $n-committed transactions at t#e time of snaps#ot "as ta7en' t is ver& $sef$l for report H$eries' (T#is option is available in 2005 .. edition E ?- , ./T. /T/A/S. /dvent$re9or7sIdbss1)00 O3 ( 3/M. K /dvent$re9or7sI ata! E L.3/M. K ,?UProgram EilesUMicrosoft SQL ServerUMSSQL'1UMSSQLU ataU /dvent$re9or7sIdataI1)00'ss /S S3/PSNOT OE /dvent$re9or7s%
12) What is Tra sa%tio ? What is Tra sa%tio :ACID) Pro8erties? Transaction is a set of Logical $nit of "or7 and it contains one or more database operations' / valid transaction s#o$ld be met (/, /tomicit&! ,onsistenc&!
solation! $rabilit& properties' a Ato i%it3 ?- / transaction m$st be an atomic $nit of "or7! eit#er all of it data
modi<cation are performed (or none of t#em is performed' b Co siste %3 ?- 9#en completed a transaction m$st leave all data in
consistent state' n a relational database! all r$les m$st be applied to transactions modi<cations to maintain all data integrit&' /ll internal data
8/20/2019 DBA Iq Faq-praveen
str$ct$res! s$c# as A-tree inde4es (or do$ble lin7ed lists m$st be correct at end of transaction'
c Iso!atio ?- Modi<cations made b& conc$rrent transactions m$st be isolated from t#e modi<cations made b& t#e ot#er conseH$ent transactions' / transaction eit#er sees a data in t#e state it "as in before anot#er conc$rrent transaction modi<ed it! (or sees t#e data after second transaction completed'
d D/ra"i!it3 ?- /fter a transaction #as completed! its eWects are permanentl& in place in t#e s&stem' T#e modi<cation persists even in t#e event of a s&stem fail$re'
1#) What are Tra sa%tio Iso!atio !eve!s? /n solation level determines t#e degree of isolation of data bet"een conc$rrent
transactions' T#e defa$lt isolation level is ead committed'a ead $ncommitted b ead committed c epeatable read d Seriali able
1+) What is 8/r8ose o, [email protected] / "ers? .ver& record in t#e transaction log is $niH$el& identi<ed b& a log seH$ence n$mber (LS3 ' LS3s are $sed internall& d$ring a .STO . seH$ence to trac7 t#e point in time to "#ic# data #as been restored'
1 ) E 8!ai a"o/t RAID a ( RAID !eve!s? / stands for ed$ndant /rra& of ndependent is7s' / is a dis7 s&stem
t#at contains arra&s to provide greater performance! reliabilit&! storage capacit&! and lo"er cost' T&picall& 0! 1! and 5 / levels are $sed in SQL Server'
1-) I, a Data"ase i Si .!e ser o(e? o& to %ha .e i to 7/!ti*/ser o(e?
/lter database database nameB set m$ltiI$ser
10) 7i i a! 7o(e a ( Si .!e /ser o(e? Minimal mode? - Start -Br$n -B command prompt B SQLS. . '. . Xf Single $ser mode? - Start -Br$n -B command prompt B SQLS. . '. . Xm
14) Or8ha e( sers? o& to 6 ( Or8ha e( sers a ( Reso!ve the ? 9#en a A is move! attac# : detac#! restoring to diWerent instance or corresponding login is dropped! t#e $sers of t#e atabase becomes Orp#aned $sers and t#e& can6t access t#e database beca$se t#e database $sers are not mapped to S (Sec$rit& denti<er in t#e ne" instance' To (ete%t Or8ha e( /sers ?- sp_ +an%e_"sers_lo%in eport To Reso!ve Or8ha e( sers<* sp_ +an%e_"sers_lo%in pdate_One !
d#_"ser ! lo%in_name 15) What is Ro& siHe o, a Data"ase?
8/20/2019 DBA Iq Faq-praveen
http://slidepdf.com/reader/full/dba-iq-faq-praveen 9/30
o" si e of a database is )0+0 b&tes'
2') What is ea8 ta"!e? / table "it#o$t a cl$stered inde4 is called as #eap table'
21) What is Che%= 8oi t? ,#ec7 Point is a operations t#at s&nc#roni es t#e p#&sical data "it# t#e c$rrent state of t#e b$Wer cac#e b& "riting o$t all modi<ed data pages in b$Wer cac#e to dis7'
22) o& a 3 &a3s 3o/ %a ove the (ata or (ata"ases "et&ee servers a ( (ata"ases? SS S! TS! /ttac# : etac#! A$l7 cop& program! A$l7 nsert : mport and .4port
"i ard
2#) S3 ta ,or 6 ( o/t the Data"ase ID?Select dbIid ( dbIname6
2+) S3 ta ,or 6 ( o/t Lo.i s? C/rre t ser? To 6 ( o/t !o.i s ? - select Y from s&s's&slogins To 6 ( o/t %/rre t /ser ?- Select c$rrentI$ser
2 ) Is it 8ossi"!e to ta=e Ba%=/8s a ( Restores o, S3ste Data"ases?
Re%over3 7o(e!s
1) What is Re%over3 7o(e!? Be e6ts o, Re%over3 7o(e!s?/ recover& model is a atabase propert& t#at control t#e basic be#avior of t#e bac7$p and restore operations for a A ' ecover& models are designed to control transaction log maintenance'
2) E 8!ai F/!!G B/!=*Lo..e( Si 8!e Re%over3 7o(e!s? a F/!!<* 9it# E$ll ecover& Model "e can recover t#e data $p to t#e min$te
of cras#! beca$se it records ever& operation in t#e transaction log' a B/!=*Lo..e(<* 9it# A$l7-Logged recover& model "e can recover most of
t#e data! b$t "e "ill lost b$l7-operations beca$se t#ose are not recorded in to t#e log' 9e can set t#is option 8$st before performing a b$l7 insert operation to speed $p t#e b$l7 insert'
b Si 8!e< - 9it# Simple ecover& Model "e can recover t#e data onl& $p to t#e last bac7$p! beca$se not#ing is recorded in t#e transactional log' /n& c#anges made to database after t#e last bac7$p "as performed "ill be lost beca$se t#e& are not recorded in t#e transaction log' Fenerall& it is $sef$l for test and development databases or data "are#o$ses! b$t it is not appropriate c#oice for Prod$ction atabase'
#) Whi%h DBs %a &e /se Si 8!e Re%over3 7o(e!? Simple ecover& Model is $sef$l for evelopment! Test databases! ata
"are#o$ses or not often c#anged atabases' +) I Whi%h Re%over3 7o(e!s Poi t*i *ti e re%over3 is 8ossi"!e?
8/20/2019 DBA Iq Faq-praveen
Point-in-Time ecover& is Possible onl& in E$ll and A$l7-Logged ecover& Models' A$t in A$l7-Logged ecover& model Point-in-time recover& is ma& or ma& not possible'
) I S3ste DBs &hat are the (e,a/!t Re%over3 7o(e!s /se(? Master - Simple Model - E$ll MS A - Simple
Temp A - Simple
-) Wh3 i Si 8!e Re%over3 o(e! &e %a t ta=e T9Lo. "a%=/8s? n Simple ecover& Model t#e Transaction Logs are tr$ncated'
0) Ca &e ta=e Di$9 "a%=/8 i Si 8!e re%over3 7o(e!?
9e can ta7e iWerential bac7$p in Simple recover& model beca$se it belongsto 'mdf
Ba%=/8s 1) What is Ba%=/8s? T38es o, "a%=/8s?
6 op' o& data t+at is "sed to restore and re over t+e data a&ter a s'stem &ail"re7( T#ere are fo$r t&pes of Aac7$ps available (1 E$ll Aac7$p (2
iWerential Aac7$p (= Transaction Log Aac7$p (> Eile CEile Fro$p Aac7$p
2) What is se o, Ba%=/8s? Aac7$ps is Safe F$ard to atabases beca$se ata ma& can loss d$e to man&
fail$res s$c# as Media Eail$res! ;ser errors! Nard"are Eail$res and 3at$ral isasters etc' 9it# good bac7$ps! "e can recover database from fail$res'
#) What is F/!!G Di$G T9Lo. Ba=/8s? E 8!ai Ea%h? a F/!! Ba%=/8<* 8"ll #a $"p ! bac7s $p t#e entire atabase incl$ding
Transaction Log' 9it# f$ll Aac7$p Point-in-time recover& is possible beca$se it contains 'mdf and 'ldf' t oWers complete protection against media fail$res'
b Di$ere tia! Ba%=/8<* iWerential bac7$p records onl& t#e data t#at #as c#ange or modi<ed e4tents since t#e last f$ll bac7$p'
c T9Lo. Ba%=/8<* Transaction Log t#at records all transactions since last transaction log bac7$p or diWerential bac7$p' t can be $sed for recover t#e data to t#e point of fail$re (or speci<c point-in-time
d Fi!e Fi!e ;ro/8 "a%=/8<* Eile and Eile gro$p bac7$ps are a speciali ed form of A bac7$p' n "#ic# onl& certain individ$al <le (or <le gro$ps from a A are bac7$p'
+) Ca &e ta=e Di$9 "a%=/8s &itho/t F/!! "a%=/8s? 3o! it is not possible'
) What are the S3 ta es ,or Ba%=/8s?
a) F/!! Ba%=/8 ? - Ba $"p data#ase d#name to dis$ 9 6pat+7 #) Di$9 Ba%=/8 ? - Ba $"p data#ase d#name to dis$ 9 6pat+7 *it+ di:erential
8/20/2019 DBA Iq Faq-praveen
) T9Lo. Ba%=/8 ?- Ba $"p lo% d#name to dis$ 9 6pat+7
-) E 8!ai a"o/t Tai! o, Lo.? ;ive the s3 ta ? T#e tail-log bac7$p is t#e last bac7$p t#at #ave not been bac7ed $p earlier! to recover t#e database to t#e point of a fail$re' (/ bac7$p ta7en t#at #ave not been bac7ed $p 8$st before restoring a database ' S3 ta <* 1 A/, ;P LOF databaseIname TO bac7$pIdeviceB 9 TN 3O .,O . D 2 A/, ;P LOF databaseIname TO bac7$pIdeviceB Z9 TN [ ,O3T 3;.I/ET. I . O \ 3OIT ;3,/T. ]
0) Ba%=/8s strate.3? Fenerall& Aac7$ps are done b& client reH$irement' A$t Most of t#e companies are follo"ing t#is strateg&' 1 F/!! Ba%=/8 ?- .ver& Sat$rda& evening +'00 PM
2 Di$ere tia! Ba%=/8 ?- .ver& a& evening +'00 PM= Tra sa%tio a! Lo. Ba%=/8 ?- .ver& one #o$r
Restore 1) What is Restore? What are the re%over3 states? E 8!ai Ea%h?
estore means recover t#e data from bac7$ps' T#ere are t#ree recover& states for estore' (1 9it# ecover& (2 9it# 3o- ecover& (= Standb&' a With Re%over3 ?- 9it# ecover&! atabase "ill comes to Online and get
read& to $sing atabase' Fenerall& "#ile restoring recent (last T'Log "e can c#oose "it# recover& option'
b With @o*Re%over3 ?- 9it# 3o- ecover& atabases "ill comes to OVine and "e can6t access A' Fenerall& e4cept recent log "e can c#oose 9it# 3o- ecover& option'
c Sta ("3<* 9it# Standb&! atabases "ill comes to OVine and $sers can #ave read onl& access' Fenerall& e4cept recent log "e can c#oose Standb& option for ead onl& access'
2) What are the %o o s%e arios to Restori . the Data? 1 To restore t#e lost and corr$pted data after a s&stem fail$re 2 To restore a database onto a development s&stem for $ser b& application
developers "#ile developing and testing ne" code' = To restore a database onto a test s&stem to load test applications and
database feat$res' > To restore a database on separate server as a read-onl& database to
perform H$eries for reports'
#) I &hi%h e(itio O *!i e restoratio is 8ossi"!e? On-line restoration is possible onl& in .nterprise edition'
+) What are the S3 ta es ,or Restore? a With Re%over3 ?- estore database dbname from dis7 K Pat# "it#
b With @o*Re%over3 ?- estore database dbname from dis7 K Pat# "it#no recover& c Sta ("3 ?- estore database dbname from dis7 K Pat# "it# no standb&
8/20/2019 DBA Iq Faq-praveen
) What is Poi t*i *ti e restore a ( /se o, that? Point-in-time restore is $sed to restore t#e atabase to a partic$lar time 8$st before a fail$re #as occ$rred or before corr$pt data'
-) E 8!ai a"o/t STOPAT %!a/se? STOP/T cla$se is $sed to restore a data base at point of time'
0) Restore Strate.3? 1' Eirst restore recent last f$ll bac7$p 2' T#en restore last iW' bac7$p =' T#en restore all Transaction Log bac7$ps'
Lo.shi88i .1) What is Lo. shi88i . a ( 8/r8ose o, Lo. shi88i .? To ac#ieve #ig# availabilit& and #ig# protection! Log s#ipping copies transactions from a primar& server6 to one or more secondar& servers6' n Log s#ipping! T'Log bac7$ps are sent to one or more secondar& servers and t#en restored to t#e destination servers individ$all&' f t#e Primar& database becomes $navailable! an& of t#e secondar& database can bro$g#t into online man$all&' T#e Secondar& server acts as a Aac7$p server and provides read-onl& H$er& processing to red$ce t#e load on t#e Primar& server' (Eor H$er& processing! secondar& servers s#o$ld be con<g$re in stand-b& mode '
2) What is Pri ar3 ServerG Se%o (ar3 Server 7o itor Server? a Pri ar3 Server ? - Primar& Server is a Prod$ction server "#ic# #olds t#e
original cop& of t#e database' Log s#ipping con<g$ration and administrating "ill be done from Primar& Server'
b Se%o (ar3 Server ? - Secondar& servers #old t#e standb& cop& of t#e database' 9e m$st initiali e t#e A on a secondar& server b& restoring a bac7$p from t#e Primar& server $sing eit#er 3O .,O . D option or t#e ST/3 AD option' A& $sing ST/3 AD option ;sers can #ave read-onl& access to it'
c 7o itor Server ? - /n optional Server is called as Monitor Server t#at records #istor& and stat$s of bac7$p! cop& and restore operations and raises alerts if an& operations fail' T#e Monitor Sever s#o$ld be on separate server to avoid losing critical information' Single Monitor Server monitors m$ltiple Log s#ipping con<g$rations'
#) What are the Jo"s r/ i . ,or Lo. shi88i . a ( e 8!ai the ? Log s#ipping #aving fo$r operations "#ic# are #andled b& SQL Server /gent @ob' a Ba%=/8 Jo" ? - Aac7$p 8ob is created on Primar& Server instance and it
performs bac7$p operation' t logs #istor& on t#e local server and monitor severs and deletes old bac7$p <les and #istor& information'
b Co83 Jo" ? - ,op& @ob is created on Secondar& server instance and it performs
copies t#e bac7$p <les from primar& sever to secondar& server' t logs #istor&on t#e secondar& server and monitor server'
8/20/2019 DBA Iq Faq-praveen
c Restore Jo" ? - estore @ob is created on t#e Secondar& server instance and it performs restore operation' t logs #istor& on t#e local server and monitor sever and deletes old <les and #istor& information'
d A!ert Jo"< * f a Monitor Server is $sed! t#e /lert @obs is created on t#e Monitor server instance and it raises /lerts if an& operations #ave not completed s$ccessf$ll&'
+) Re /ire e ts ,or Lo. shi88i .? a SQL Server 2005 Standard .dition! 9or7gro$p .dition! or .nterprise .dition
m$st be installed on all server instances involved in log s#ipping' b /ll servers s#o$ld #ave t#e same case sensitivit& settings' c T#e databases m$st $se t#e f$ll recover& model or b$l7-logged recover&
) o& to %o 6./re Lo. shi88i .?
a' ,#oose Primar& Server! Secondar& Servers! and optional Monitor server'b' ,reate a Eile s#are to 7eep Transaction log bac7$ps (Aest to place on a separate comp$ter
c' ,reate a folder for eac# Secondar& server into "#ic# transaction log bac7$p copies'
d' ,#oose Aac7$p Sc#ed$le for Primar& atabase e' ,#oose ,op& and estore Sc#ed$les for Secondar& atabase f' ,#oose /lert @ob sc#ed$le for Monitor Server if con<g$red
-) What are 8er issio s re /ire( ,or Lo. shi88i .? 9e m$st #ave sysadmin on eac# server instance to con<g$re Log s#ipping'
0) I Lo.shi88i . &hi%h Re%over3 7o(e!s %a &e /se(? 9e can $se eit#er f$ll or b$l7 logged recover& model for log s#ipping'
4) Where 3o/ o itori . Lo. shi88i . a ( ho&? 9e can monitoring t#e Log s#ipping in t#e follo"ing "a&s' a 7o itor server : istor3 Ta"!es) ?- Monitor Server trac7s all statistics! stat$s
and errors t#at co$ld be #appen d$ring Log s#ipping' 1 Lo.Kshi88i .K o itorK8ri ar3 ?- Stores primar& server stat$s 2 Lo.Kshi88i .K o itorKse%o (ar3 ?- Stores secondar& servers stat$s = Lo.Kshi88i .K o itorKhistor3K(etai!< - ,ontains #istor& details for
logs#ipping agents' > Lo.Kshi88i .K o itorKerrorK(etai! ?- Stores error details for log s#ipping
8obs' 5 Lo.Kshi88i .K o itorKa!ert ?- Stores /lert @ob
b S3ste Store( Pro%e(/res :7SDB) ?- S&stem Stored proced$res gives t#e #istor& information abo$t t#e speci<ed server t#at are con<g$red in Log s#ipping' 1 spI#elpIlogIs#ippingImonitor ( $n at Monitor Server 2 spI#elpIlogIs#ippingImonitorIprimar& JPrimar&I atabase K A3ame6
( $n at MS= spI#elpIlogIs#ippingImonitorIsecondar& J Secondar&I atabase K A3ame6 ( $n at MS
8/20/2019 DBA Iq Faq-praveen
> spI#elpIlogIs#ippingIalertI8ob ( $n at Mon Server 5 spI#elpIlogIs#ippingIprimar&Idatabase J atabase K A3ame6 ( $n at
Primar& Server + spI#elpIlogIs#ippingIsecondar&Idatabase J atabase K A3ame6 ( $n
at Sec Server c Tra sa%tio Lo. shi88i . Stat/s re8ort :S/ ar3 Re8orts) ?- T#is
report s#o"s t#e stat$s of log s#ipping con<g$rations for "#ic# t#is server instance is a primar&! secondar& or monitor'
d SQL Server /gent @ob Nistor& e ,#ec7ing t#e SQL Server Log
5) o& Se%o (ar3 Server &i!! "ro/.ht i to O !i eG i, the Pri ar3 Server "e%o es avai!a"!e?
f t#e Primar& Server "ill become $n-available! do t#e follo"ing steps' a Ta7e t#e Tail of Log from Primar& server
b estore Tail of log into all Secondar& atabasec emove Log-s#ipping con<g$ration from Primar& Server d Select an& one of Secondar& server and bring into online "it# /lter atabase
A3ame set Online e ig#t clic7 on Primar& atabase and Fenerate script for ;sers and Logins' f T#en move t#e script to Secondar& server to create ;sers and Logins g e-con<g$re log s#ipping from 3e" Server (Secondar& server
1') What are errors o%%/rre( i Lo. shi88i .? T#ere are t"o errors are occ$rred d$ring Log s#ipping 1 1++2' ?- T#is error occ$rs "#en t#e Aac7$p 8ob fails
2 1++21 ?- T#is error occ$rs "#en t#e estoring 8ob fails
7irrori . 1) What is Data"ase 7irrori .? What are the "e e6ts o, that?
atabase mirroring is a met#od of increasing database availabilit& ! "#ic# s$pports a$tomatic failover "it# no loss of data' Be e6ts ?- # ncreases data protection i ncreases availabilit& of a database
8 mproves t#e availabilit& of t#e prod$ction database d$ring $pgrades
2) What are the 8rere /isites ,or Data"ase 7irrori .? a Aot# Servers are reH$ires same edition eit#er Standard .dition or
.nterprise .dition' b f 9itness server con<g$red! t#e server s#o$ld be installed Standard
.dition! .nterprise .dition! 9or7gro$p .dition! or .4press .dition' c /ll Servers s#o$ld $se t#e same master code page and collation' d Mirror Server #as same database name and $se onl& 9it# 3o ecover&
option' e Mirroring $ses t#e f$ll recover& model' (Simple and b$l7-logged not
s$pportedf /ll logins for connecting Principal atabase s#o$ld be reside on Mirror database
8/20/2019 DBA Iq Faq-praveen
#) What are the Restri%tio s ,or Data"ase 7irrori .? a Ma4im$m 10 databases per instance can s$pport on a =2-bit s&stem' b atabase mirroring is not s$pported "it# eit#er cross-database
transactions or distrib$ted transactions'
+) E 8!ai a"o/t Pri %i8a!G 7irror a ( Wit ess Servers? 1 Pri %i8a! Server ?- One Server serves t#e database to client is called
Principal server and it #aving original data' ,an #ave onl& one Principal Server and it #as to be on a separate server'
2 7irror Server ?- Ot#er server instance acts as a #ot or "arm standb& server is called Mirror server and it #aving cop& of database'
= Wit ess Server ?- T#e "itness server is an optional server and it controls a$tomatic failover to t#e mirror if t#e principal becomes $navailable' To s$pport a$tomatic failover! a database mirroring session m$st be
con<g$red in #ig#-availabilit&' ) I &hi%h O8eratio s are r/ i . the O8erati . 7o(es?
As3 %hro o/s ?- ;nder as&nc#rono$s operation! t#e Principal server does not "ait for a response from t#e mirror server after sending t#e log b$Wer' S3 %hro o/s ?- ;nder s&nc#rono$s operation! t#e Principal server sends t#e log b$Wer to t#e mirror server! and t#en "aits for a response from t#e mirror server'
-) What are the O8erati . 7o(es a ( e 8!ai the ?
a' i.h Avai!a"i!it3 ?- Nig#-availabilit& mode! r$ns s&nc#rono$sl&' eH$ires a 9itness Server instance' T#e Principal server sends t#e log b$Wer to t#e mirror server! and t#en "aits for a response from t#e mirror server'
b' i.h Prote%tio ?- Nig#-protection mode! r$ns s&nc#rono$sl&' /l"a&s commit c#anges at bot# t#e Principal and Mirror'
c' i.h Per,or a %e ?- Nig#-performance mode! r$ns as&nc#rono$sl& and t#e transaction safet& set to oW' T#e Principal server does not "ait for a response from t#e mirror server after sending t#e log b$Wer' T#e principal server r$nning nice and fast! b$t co$ld lose data on t#e mirror server'
0) What is the (e,a/!t o, Port / "ers o, Pri %i8a! a ( 7irror servers? o& to 6 ( the Port / "ers?
T#e defa$lt port n$mbers of principal and mirror servers are 5022 and 502=' To Fi ( Port @/ "er ?- SELE; name! port 8 O< s's(t p_endpoints
4) What is E ( Poi t? o& / %reate e ( 8oi t? /n endpoint is a net"or7 protocol "#ic# is $sed to comm$nicate over t#e net"or7' Creatio o, a e ( 8oi t ?
,reate endpoint endpoint nameB StateKstartedCstoppedCdisabled as tcp (listener portK5022C502= for databaseImirroring
(roleKpartnerC"itness 5) Whi%h Tra%e a. is /se( i 7irrori .?
8/20/2019 DBA Iq Faq-praveen
Trace Rags are $sed to temporaril& set speci<c server c#aracteristics or to s"itc# oWCon a partic$lar be#avior' 1>00 Trace Rag is $sed in mirroring' To set tra%e a. ,or Data"ase irrori . ?- ,on<g$ration Manager B
ig#t clic7 on server instance B Properties B /dvanced tab B Start$p parameters B -t1>00 (add
1') I &hi%h Re%over3 o(e! &e %a /se i 7irrori .? n mirroring t#e principal and mirror databases are $sed onl& f$ll recover&
11) What is Ro!e*s&it%hi .? nter c#anging of roles li7e principal and mirror are called role s"itc#ing'
12) What is the S3 ta to sto8 the Data"ase 7irrori .? /lter database database nameB set partner oW
1#) o& to %o 6./re 7irrori .? a ,#oose Principal Server! Mirror Server! and optional 9itness server' b T#e principal and mirror server instances m$st be r$nning t#e same
edition eit#er Standard .dition or .nterprise .dition c T#e 9itness server instance can r$n on SQL Server Standard .dition!
.nterprise .dition! 9or7gro$p .dition! or .4press .dition d Mirror database reH$ires restoring a recent bac7$p and one or more T'log
bac7$ps of t#e principal database ("it# 3orecover&
1+) o& to o itori . 7irrori .? T#ere are si4 met#ods are available for monitoring t#e atabase Mirroring a SQL Server 7a a.e e t St/(io ?- / green arro" on t#e mirror server is
indicates r$nning "ell' / red arro" indicates problems t#at need to investigate'
b SQL Server Lo. ?- t provides information of Mirroring establis#ment and stat$s' f an& errors occ$rs it "ill be logged to SQL Server log and 9indo"s event log'
c Per,or a %e 7o itor ?- t can provides real-time information abo$t atabase mirroring' 9e can $se performance co$nters to get stat$s of t#e
database mirroring s$c# as A&tes receivedCsec! A&tes sentCsec! Transaction dela& etc'
d Pro6!er ?- Pro<ler man& events are providing t#e stat$s of t#e atabase mirroring
e Data"ase 7irrori . 7o itor ?- atabase Mirroring Monitor is a F; tool t#at s#o"s $pdate stat$s and to con<g$re "arning t#res#olds' To o8e D7 7o itor ?- ig#t clic7 on Principal atabase B Tas7s B Select La$nc# atabase Mirroring Monitor'
f S3ste Store( Pro%e(/res< - 2' spIdbmmonitoraddmonitoring
=' spIdbmmonitorc#angemonitoring>' spIdbmmonitor#elpmonitoring 5' spIdbmmonitordropmonitoring
8/20/2019 DBA Iq Faq-praveen
1 ) What is ar(e i .? /s H$ic7l& as possible! t#e log b$Wer is "ritten to t#e transaction log on dis7! a process called #ardening'
1-) What is Lo. "/$er / log b$Wer is a special location in memor& ( /M ' SQL Server stores t#e c#anges in t#e database6s log b$Wer' 10) o& to Set a Wit ess Server to Data"ase 7irrori .?
SS7S ?- ig#t ,lic7 on Principal atabase B Tas7s B Mirror B ,lic7 on ,on<g$re Sec$rit& B Provide t#e .nd point for 9itness server B ,lic7 o T*SQL ?- /LT. /T/A/S. /dvent$re9or7s S.T 9 T3.SS K
T,P?CCprasad'local?502> ( o t#is from t#e Principal Server
14) o& to Re ove a Wit ess Server ,ro Data"ase 7irrori .?
SS7S ?- ig#t ,lic7 on Principal atabase B Tas7s B Mirror B emove T,Paddress from t#e 9itness B ,lic7 o T*SQL ?- /LT. /T/A/S. /dvent$re9or7s S.T 9 T3.SS OEE
15) o& to Set/8 F/!!3 Q/a!i6e( @a es ,or Data"ase 7irrori .? I9 [email protected] Error One or more of t#e server net"or7 addresses lac7s a f$ll& H$ali<ed domain name (EQ 3 ' Specif& t#e EQ 3 for eac# server! and clic7 Start Mirroring again'
T#e s&nta4 for a f$ll&-H$ali<ed T,P address is?
T,P?CC comp$terInameB' domainIsegmentBZ' domainIsegmentB^? portB
II9 RECTIF [email protected]; F LL Q ALIF ED @A7ES 1 To Vie& E (8oi ts<* S.L.,T Y E OM s&s'databaseImirroringIendpoints% 2 Re ove e isti . a!! E (8oi ts ,ro Pri %i8a!G 7irror a ( Wit ess
servers <* OP .3 PO 3T Z.3 PO 3TI3/M.^ #) A((i . M!o%a!M as the 8ri ar3 [email protected] s/N as ,o!!o&s<*
a ig#t-clic7 73 Co 8/ter ! and t#en clic7 Pro8erties ' T#e S&stem Properties dialog bo4 "ill appear'
b ,lic7 t#e Co 8/ter @a e tab' c ,lic7 Cha .e ' T#e Co 8/ter @a e Cha .es dialog bo4 "ill appear' d ,lic7 7ore ' T#e [email protected] S/N a ( @etBIOS Co 8/ter @a e dialog
bo4 "ill appear' e .nter t#e appropriate 3S s$G4 for t#e domain' f Select t#e Cha .e 8ri ar3 [email protected] s/N &he (o ai e "ershi8
%ha .es c#ec7 bo4' g ,lic7 O to save t#e c#anges! and t#en clic7 O to e4it t#e Co 8/ter
@a e Cha .es dialog bo4' # ,lic7 O to close t#e S3ste Pro8erties dialog bo4! and t#en restart
t#e comp$ter for t#e c#ange to ta7e eWect'> econ<g$re t#e atabase mirroring eit#er F; or T-SQL
8/20/2019 DBA Iq Faq-praveen
2') What are the Data"ase 7irrori . states? 1) S @C [email protected] [email protected];<*
T#e contents of t#e mirror database are lagging be#ind t#e contents of t#e principal database' T#e principal server is sending log records to t#e mirror server! "#ic# is appl&ing t#e c#anges to t#e mirror database to roll it for"ard'
/t t#e start of a database mirroring session! t#e database is in t#e SD3,N O3 _ 3F state' T#e principal server is serving t#e database! and t#e mirror is tr&ing to catc# $p'
2) S @C [email protected] ED ?- 9#en t#e mirror server becomes s$Gcientl& ca$g#t $p to t#e principal
server! t#e mirroring state c#anges to SD3,N O3 _. ' T#e database remains in t#is state as long as t#e principal server contin$es to send c#anges to t#e mirror server and t#e mirror server contin$es to appl& c#anges to t#e mirror database'
f transaction safet& is set to E;LL! a$tomatic failover and man$alfailover are bot# s$pported in t#e SD3,N O3 _. state! t#ere is no data loss after a failover'
f transaction safet& is oW! some data loss is al"a&s possible! even in t#e SD3,N O3 _. state'
#) S [email protected]<* T#e mirror cop& of t#e database is not available' T#e principal
database is r$nning "it#o$t sending an& logs to t#e mirror server! a
condition 7no"n as r"nnin% e posed ' T#is is t#e state after a failover' / session can also become S;SP.3 . as a res$lt of redo errors or if t#e administrator pa$ses t#e session S;SP.3 . is a persistent state t#at s$rvives partner s#$tdo"ns and start$ps'
+) [email protected]@;KFAILOVER<* T#is state is fo$nd onl& on t#e principal server after a failover #as beg$n! b$t t#e server #as not transitioned into t#e mirror role' 9#en t#e failover is initiated! t#e principal database goes into t#e P.3 3FIE/ LO . state! H$ic7l& terminates an& $ser connections! and ta7es over t#e mirror role soon t#ereafter'
) [email protected]@ECTED<* T#e partner #as lost comm$nication "it# t#e ot#er partner
Re8!i%atio 1) What is Re8!i%atio ?
eplication is t#e process of cop&ing and distrib$ting data bet"een databases to diWerent servers t#ro$g#o$t t#e enterprise '
eplication is a set of tec#nologies for cop&ing and distrib$ting data and database ob8ects from one database to anot#er and t#en s&nc#roni ing bet"een
databases to maintain consistenc&' 2) What are the /ses o, Re8!i%atio ?
8/20/2019 DBA Iq Faq-praveen
a Server to Server Re8!i%atio ?- 1' mproving scalabilit& and availabilit& 2' ata "are#o$sing and reporting =' ntegrating data from m$ltiple sites >' ntegrating #eterogeneo$s data 5' OVoading batc# processing
b Server to C!ie t Re8!i%atio ?- 1' .4c#anging data "it# mobile $sers 2' etail point of sale (POS applications =' ntegrating data from m$ltiple sites
#) T38es o, Re8!i%atio a ( e 8!ai ea%h? a S a8shot re8!i%atio ?- Snaps+ot repli ation ta7es a pict$re or a snaps#ot of
t#e database and propagated to t#e s$bscribers' t red$ces t#e over#ead on t#e P$blis#ers and S$bscribers beca$se it does not monitor data $pdates'
Snaps#ot replication is ver& $sef$l! "#en t#e so$rce data is c#angesoccasionall& ( eporting ' b Tra sa%tio a! re8!i%atio ?- Transactional eplication starts "it# a snaps#ot
of t#e p$blis#er database' 9it# Transactional eplication! an& c#anges made to t#e articles are capt$red from t#e transactional log and propagated to t#e distrib$tors contin$o$sl& and a$tomaticall&' ;sing Transactional eplication "e can 7eep t#e p$blis#er and s$bscriber in almost e4actl& t#e same state'
c 7er.e re8!i%atio ?- Merge eplication starts "it# a snaps#ot of t#e p$blis#er database' S$bseH$ent data c#anges and sc#ema modi<cations made at t#e P$blis#er and S$bscribers are trac7ed "it# triggers' T#e S$bscriber s&nc#roni es "it# t#e P$blis#er "#en connected to t#e net"or7 and
e4c#anges all ro"s t#at #ave c#anged bet"een t#e P$blis#er and S$bscriber since t#e last time s&nc#roni ation occ$rred'
+) E 8!ai a"o/t P/"!isherG S/"s%ri"er a ( Distri"/ter? a P/"!isher ?- T#e P$blis#er is a database t#at ma7es data available for
replication' T#e P$blis#er can #ave one or more p$blications' b Distri"/tor<* T#e distri#"tor is t#e intermediar& bet"een t#e p$blis#er and
s$bscriber' t receives p$blis#ed transactions or snaps#ots and t#en stores and for"ards t#ese p$blications to t#e s$bscribers'
c S/"s%ri"ers<* S$bscribers are database servers t#at store t#e replicated data and receive $pdates' / s$bscriber can receive data from m$ltiple p$blis#ers' Aased on t#e replication t&pe! t#e S$bscriber can also pass data c#anges bac7 to t#e P$blis#er or rep$blis# t#e data to ot#er S$bscribers'
) E 8!ai a"o/t Arti%!eG P/"!i%atio G S/"s%ri8tio ? a Arti%!e ?- /n rti le is t#e data! transactions! or stored proced$res t#at are
stored "it#in a p$blication' T#is is t#e act$al information t#at is going to be replicated'
b P/"!i%atio ?- T#e p"#li ation is t#e storage container for diWerent articles' /s$bscriber can s$bscribe to an individ$al article or an entire p$blication'
8/20/2019 DBA Iq Faq-praveen
c S/"s%ri8tio ?-S$bscription is a reH$est b& t#e s$bscriber to receive t#e p$blication'
-) Whi%h re%over3 o(e!s are /se( ,or Re8!i%atio ? E$ll and A$l7-logged ecover& models
0) o& to o itor the Re8!i%atio ? a Re8!i%atio 7o itor ?- eplication Monitor is a F; tool provides detailed
information on t#e stat$s and performance of p$blications and s$bscriptions' A& $sing replication monitor "e can <nd o$t (1 "#ic# s$bscriptions are slo" (2 9#& is an agent not r$nning (= Time ta7en to transaction commit (> 9#& merge replication is slo" (5 No" far be#ind s$bscription etc' To !a/ %h Re8!i%atio 7o itor ?- ,onnect nstance B ig#t ,lic7 on
eplication folder B Select la$nc# eplication monitor
b 7a a.e e t St/(io ?- A& $sing management St$dio "e can see ie"Snaps#ot /gent Stat$s! ie" Log eader /gent Stat$s! ie" S&nc#roni ation Stat$s etc' Thro/.h SS7S ?- ,onnect nstance B ig#t ,lic7 on P$blication B Select t#e option
c S3ste 7o itor ?- Provides information on t#e performance of vario$s processes of eplication'
A.e t Per,or a %e o" e%t Co/ ter
/ll agents eplication /gents $nning
Snaps#ot /gent
eplication Snaps#ot
/gent eplication ist' ist? elivered TransCsec
istrib$tion /gent eplication ist' ist? eliver& Latenc&
Merge /gent eplication Merge ,onRictsCsec
Merge /gent eplication Merge o"nloaded ,#angesCsec
Merge /gent eplication Merge ;ploaded ,#angesCsec
4) What are the A.e ts avai!a"!e ,or Re8!i%atio a ( e 8!ai ea%h? SQL Server /gent #osts and sc#ed$les t#e agents $sed in replication and also controls and monitors operations o$tside of replication'
8/20/2019 DBA Iq Faq-praveen
b S a8shot A.e t ?-T#e Snaps#ot /gent is t&picall& $sed for all t&pes of replication' t is responsible for cop&ing t#e sc#ema and data from t#e p$blis#er to t#e s$bscribers! stores t#e snaps#ot <les! and records information abo$t s&nc#roni ation in t#e distrib$tion database' T#e Snaps#ot /gent r$ns at t#e istrib$tor'
c Lo. Rea(er A.e t ?- T#e Log eader /gent is $sed for transactional replication' t moves information from t#e transaction log on t#e p$blis#er to t#e distrib$tion database'
d Distri"/tio A.e t ?- T#e istrib$tion /gent is $sed for snaps#ot replication and transactional replication' t is responsible for moving t#e stored transactions from t#e distrib$tor to t#e s$bscribers'
e 7er.e A.e t ?- T#e Merge /gent is $sed for merge replication' t is responsible for converging records from m$ltiple sites and t#en redistrib$ting t#e converged records bac7 to t#e s$bscribers'
f Q/e/e Rea(er A.e t ?- T#e Q$e$e eader /gent is $sed for transactional
replication "it# t#e H$e$ed $pdating option' t r$ns on t#e istrib$tor and isresponsible for reading messages from t#e H$e$e on t#e s$bscribers and appl&ing t#em to t#e appropriate p$blication'
5) What are the A.e ts /se( ,or Tra sa%tio a! Re8!i%atio ? a Snaps#ot /gent b Log eader /gent c istrib$tion /gent
1') What are the A.e ts /se( ,or 7er.e Re8!i%atio ? a Snaps#ot /gent
b Merge /gent
11) What is the Pro%ess o, Tra sa%tio a! Re8!i%atio ? T#ree /gents are doing t#e Process for Transactional eplication
[email protected];[email protected]
1) What is 7ai te a %e P!a ? Maintenance plans create a "or7Ro" for database optimi ation! and ma7e free from inconsistencies'
2 9#at t#e tas7s in Maintenance Plans`
= SQL Server Logs`
+) Data"ase 7ai!? atabase Mail is an enterprise sol$tion for sending e-mail messages from t#e
Microsoft SQL Server 2005 atabase .ngine' ;sing atabase Mail! &o$r databaseapplications can send e-mail messages to $sers' T#e messages can contain
8/20/2019 DBA Iq Faq-praveen
H$er& res$lts! and can also incl$de <les from an& reso$rce on &o$r net"or7' atabase Mail is designed for reliabilit&! scalabilit&! sec$rit&! and s$pportabilit&'
5 E$ll Te4t Searc#`
[email protected] T @[email protected]; 1) Whi%h Too!s are /se( ,or Per,or a %e T/ i .?
T#ere are man& tools are $sed for Performance t$ning a Wi (o&s too!s ,or o itori . a88!i%atio s ?- Performance monitor!
Performance ,o$nters and Logs! Tas7 manager! 3et"or7 manager b SQL Server too!s ,or o itori . %o 8o e ts ?- SQL trace! SQL
Pro<ler! M s! S&stem Stored proced$res! Frap#ical s#o" plan! /ctivit& Monitor! A,,! A$ilt-in E$nctions! Trace Rags
2) o& to i(e ti,3 !o .est r/ i . /eries? T#ere are t"o "a&s to identif& slo" r$nning H$eries 1 Pro<ler (A& $sing d$ration of t#e H$er& 2 s&s'dmIe4ecIH$er&Istats and s&s'dmIe4ecIreH$ests M s = A,, OP.3T /3
#) Reaso s ,or S!o& R/ i . Q/er3? T#ere are a n$mber of common reasons for slo"-r$nning H$eries a Lac7 of $sef$l inde4es! Lac7 of $sef$l data striping ( / ' b Aloc7ings! Table scans! Lac7 of $sef$l partitioning
c Missing or o$t of date statistics ($pdate statistics d Slo" net"or7 comm$nication' e ns$Gcient memor& available for SQL Server' f ns$Gcient dis7 space' g .4cess recompilations of Stored Proced$res # Proced$res and Triggers "it#o$t S.T 3O,O;3T On
+) o& to a a!3He /er3 8er,or a %e? 9e can anal& e H$er& performance in t#ree "a&s 1 T*SQL ?- S.T SNO9PL/3I/LL O3COEE! S.T SNO9PL/3IT. T O3COEE 2 SS7S ?- .stimated .4ec$tion Plan : /ct$al .4ec$tion plan = Pro6!er ?- To displa& te4t and ML e4ec$tion plans! see ispla&ing
.4ec$tion Plans b& ;sing SQL Server Pro<ler .vent ,lasses
) o& to i %rease Q/er3 8er,or a %e? 9e can improve H$er& performance in t#e follo"ing "a&s 1 /dd inde4es if reH$ired 2 $n ;pdate statistics for o$t of date statistics = esolving Aloc7ing iss$es > /dd space to A <les or Temp A! if t#at are not #aving eno$g# space
5 ed$ce t#e too m$c# normali ation+ ;sing Temporar& tables instead of ,$rsors * SPs and Triggers are "it# Set 3O,O;3T On
) ;nnecessaril& complicated 8oins
-) E 8!ai a"o/t Pro6!er? What are the ses o, Pro6!er? SQL Pro<ler can capt$re SQL Server events from t#e server to anal& e or tro$bles#oot performance problems s$c# as Einding Slo"-r$nning H$eries and Monitoring performance etc' Pro<ler is $sef$l for maintaining sec$rit&! tro$bles#ooting! monitoring and optimi ation'
ses o, SQL Pro6!er<* a Eind t#e "orst-performing H$eries' b dentif& t#e ca$se of a deadloc7' c Monitor stored proced$re performance d /$dit SQL Server activit&' e Monitoring T-SQL activit& per $ser' f ,ollect a representative sample of events for stress testing' g ,ollect a sample of events for t$ning t#e p#&sical database design b&
$sing atabase .ngine T$ning /dvisor' 0) What are the Eve ts is %a8t/re( SQL Pro6!er?
9e can capt$re t#e events s$c# as a T-SQL Statements! Stored Proced$res b ,$rsors! Loc7s (deadloc7s c atabases ob8ects and a$to gro"t# of si e of data : log <les d .rrors : "arnings (s&nta4 errors e Performance (s#o" plan f Table Scans g Sec$rit& a$dits (failed logins! pass"ord c#anges
# Monitor server control! memor& c#anges (,P;! eads! 9rites i Sessions! Transactions! T$ning
4) E 8!ai a"o/t Data"ase T/ i . A(visor? What is Wor=!oa(? atabase T$ning /dvisor can anal& e t#e performance eWects of "or7loads
r$n against one or more atabases or a SQL Pro<ler trace (t#e& ma& contain T-SQL batc# or remote proced$re call ' /fter anal& ing! it recommends to add! remove or modif& p#&sical design str$ct$res s$c# as cl$stered and non- cl$stered inde4es! inde4ed vie"s and partitioning' Wor=!oa( ?- / "or7load is a set of Transact-SQL statements t#at e4ec$tes against databases &o$ "ant to t$ne
5) What is D3 a i% 7a a.e e t Vie&s? M s ret$rn server state information t#at "e can $se to monitor t#e #ealt#
of a server instance! diagnose problems! and t$ne performance' T#ere are t"o t&pes of M s? a Server*s%o8e( D7Vs<* eH$ire t#e .9 S. . ST/T. permission on
t#e server'
b Data"ase*s%o8e( D7Vs<* eH$ire t#e .9 /T/A/S. ST/T.permission on t#e database'
8/20/2019 DBA Iq Faq-praveen
1') What is DAC? o& to %o e%t DAC? /, is stands for edicated /dministrator ,onnection' T#is diagnostic
connection allo"s an administrator to access r$nning instance to tro$bles#oot problems or e4ec$te diagnostic H$eries on t#e server - even "#en SQL Server is not responding to standard connection reH$ests' T#is connection $ses 1>=> port and can connect onl& one connection per instance' To %o e%t DAC ?- 1) SQLC7D ?- *Sa( i < =instan e_name, 2) ; I ?- SSMS Q$er& .ditor b& connecting to ADMIN < instan e_name,
11) E 8!ai a"o/t Data"ase Co so!e Co a (s :DBCC)? A,, ,ommands are $sed to c#ec7 t#e consistenc& of t#e atabases or atabase Ob8ects' 9#ile e4ec$ting A,, commands t#e A engine creates a
database snaps#ot and t#en r$ns t#e c#ec7s against t#is snaps#ot' /fter t#e
A,, command is completed! t#is snaps#ot is dropped' 12) What is Store( Pro%/re? What are the t38es o, store( Pro%e(/res
avai!a"!e i SQL server a ( e 8!ai ea%h? / stored proced$re is a precompiled e4ec$table ob8ect t#at contains one or more Transact-SQL statements'
a ser De6 e( Store( Pro%e(/re ?- Stored proced$res are mod$les or ro$tines t#at encaps$late code for re$se' / stored proced$re can ta7e inp$t parameters! ret$rn tab$lar or scalar res$lts and messages to t#e client
b S3ste Store( Pro%e(/re ?- S&stem stored proced$res are $sed to
perform man& administrative and informational activities' c E te (e( store( 8ro%e(/re ?- .4tended stored proced$res are $sed to
create o"n e4ternal ro$tines in a programming lang$age s$c# as ,' .4tended stored proced$res are LLs t#at an instance of Microsoft SQL Server can d&namicall& load and r$n'
1#) What is A%tivit3 7o itor a ( /se o, that? What are the 8er issio s re /ire( to /se A%tivit3 7o itor? /ctivit& Monitor is $sed to get information abo$t $sers connections to t#e
atabase .ngine and t#e loc7s t#at t#e& #old' /ctivit& Monitor is $sed to tro$bles#ooting database loc7ing iss$es! and to terminate a deadloc7ed or $nresponsive process' To /se a%tivit3 o itor ?- VIEW SERVER STATE permission on Server and SELECT permission to t#e s3s8ro%esses : s3s!o%=s tables in t#e master database' To i!! a Pro%ess ?- s3sa( i and 8ro%essa( i database roles and permission are reH$ired to ILL a process'
1+) What is E e%/tio P!a a ( e 8!ai it?
.4ec$tion Plan grap#icall& displa&s t#e data retrieval met#ods c#osen b&
SQL Server' t represents t#e e4ec$tion cost of speci<c statements andH$eries in SQL Server' T#is grap#ical approac# is ver& $sef$l for $nderstanding t#e performance of t#e H$er&'
8/20/2019 DBA Iq Faq-praveen
21) What is Tra%e a.? ;ive so e Tra%e a.s? Trace Rags are $sed to temporaril& set speci<c server c#aracteristics or to s"itc# oWCon a partic$lar be#avior' T#ere are t"o t&pes of trace Rags? session and global' Session trace Rags are active for a connection and are visible onl& to t#at connection' Flobal trace Rags are set at t#e server level and are visible to ever& connection on t#e server' Some Rags can onl& be enabled as global! and some can be enabled at eit#er global or session scope' (1 2+0 (2 120> (= 1211 (> 1222 (5 122> (+ 252) (* =205 () =+25 ( >+1+ (10 *)0+ (11 1>00 To set o o$ Tra%e a. ?- (1 A,, T /,.O3 (2 A,, T /,.OEE To E a"!e Tra%e a. .!o"a!!3 ?- A,, T /,.O3 "it# t#e -1 arg$ment (.4?- A,, T /,.O3 252)! -1 *T start/8 o8tio ?- ndicates t#at an instance of SQL Server s#o$ld be
started "it# a speci<ed trace Rag ( tra e> in eWect'To Deter i e tra%e F!a.s are %/rre t!3 a%tive ?- A,, T /,.ST/T;S
1 ) What are the %o o ,ai!/res o%%/r i SQL Server 2'' ? T#ere are t#ree common fail$res occ$r in SQL Server 2005' 1 atabase Eail$res 2 P#&sical Server Eail$res = SQL Server Service fail$res
1-) What are the %a/ses o, Data"ase Fai!/res? T#ere are t#ree common iss$es "ill ca$ses atabase fail$res' Log Eile vie"er
is ver& $sef$l to diagnose t#ese problems t#at "ill occ$r in SQL Server 2005'1 Data"ase has r/ o/t o, Dis= s8a%e ?- a f a atabase is online! and r$nning o$t of dis7 space t#e data cannot
be inserted into t#e database' b f t#e atabase d$ring recover&! and t#e data <le becomes f$ll t#e
atabase engine mar7s t#e atabase as eso$rce Pending ' 2 T9 Lo. is ,/!! ?-
a f t#e atabase is Online! and t#e T'Log becomes f$ll t#e atabase .ngine iss$es 002 error and it is in read-onl& state and "ill not allo" $pdates'
b f t#e atabase d$ring recover&! and t#e T'Log becomes f$ll t#e atabase engine mar7s t#e atabase as eso$rce Pending '
= Te 8DB has r/ o/t o, Dis= s8a%e ?- Temp A stores ;ser ob8ects! nternal Ob8ects and ersion stores' f t#e Temp A database r$ns o$t of
space! it ca$ses signi<cant problems for SQL Server 2005' T#e errors are "ritten to SQL Server log and t#ese errors (1101! 1105! = 5 ! = +*! = 5)! = ++ indicates Temp A #as ins$Gcient space'
10) o& to / (ersta ( Data"ase E .i e Errors? f an& error occ$rs! t#e server "rites error messages to logs ( atabase mail!
SQL /gent! SQL Server : 9indo"s 3T ' T#ese logs #aving .rror n$mber!
.rror message! Severit&! State! Proced$re name! Line n$mber' 9e can eas&to $nderstand errors b& vie"ing Log <le vie"er'
8/20/2019 DBA Iq Faq-praveen
14) What is Severit3 !eve! i Eve t !o.? At &hat severit3 !eve!s are &ritte to the SQL Server !o.?
T#e Severit& level tells #o" bad t#e error is' /bove 1 Severit& level errors are "ritten to t#e SQL Server log'
15) What is State Attri"/te o, a error essa.e i Eve t !o.? T#e state attrib$tes provides details of "#at ca$sed t#e error'
2') What are the Ca/ses o, Ph3si%a! Server Fai!/res? T#ere are <ve common iss$es "ill ca$ses P#&sical Server fail$res' 1 is7 fail$res 2 Memor& fail$res = Processor fail$res > 3et"or7 card fail$res 5 / fail$res
21) I, Lo. 6!e is ,/!! &hat 3o/ &i!! (o? f t#e T'Log <le is f$ll t#e atabase iss$es 002 error and it is in ead-onl&
state and "ill not allo" $pdates' T#e follo"ing tas7s "ill responding T'Log <le 1 Aac7ing $p t#e log 2 /dding one or more log <les = Moving t#e Log to anot#er dis7 > ncreasing log <le si e or enabling a$to gro"t# 5 Teminating long-r$nning transactins'
22) I, Data 6!e is ,/!! &hat 3o/ &i!! (o? f t#e primar& data <le is f$ll "e can add secondar& data <les'
A((i . a 6!e to (ata"ase< * ig#t clic7 on database B Properties B Eiles B clic7 add B give t#e val$es for logical name! <le t&pe! <le gro$p! initial si e! a$to gro"t#! pat# and <le name '
2#) I, a Data"ase is / (er S/s8e%t o(e? What 3o/ &i!! (o? s8Kresetstat/s ?- esets t#e stat$s of a s$spect database ( sp_resetstat"s ? dvent"re*[email protected]
2+) I, the server has %o 8!ete!3 ,ai!e(G a ( ho& to a!! the "a%=/8s restore( o to a e& server? a A$ild t#e 9indo"s server and restore t#e domain logins to s$pport
9indo"s a$t#entication' b nstall SQL Server and an& service-pac7 $pgrades' c P$t SQL Server in single-$ser mode and restore t#e master database' d estore t#e msdb database' e f t#e model database "as modi<ed! restore it' f estore t#e $ser databases'
2 ) f a Server performance is slo"` No" &o$ can tro$bles s#oot a problem`
8/20/2019 DBA Iq Faq-praveen
2-) f a atabase Performance is slo"` No" can &o$ do Performance T$ning`
20) 9#at are t#e Performance ss$es` .4plain t#em`
[email protected] S
1) What are the Di$ere %es "et&ee De!ete Tr/ %ate? De!ete<* elete command removes t#e ro"s in a table and records in transaction log "#ic# ma7es it slo"' ollbac7 is possible' Tr/ %ate< - Tr$ncate command removes all t#e ro"s in a table! b$t it "on6t "rite log "#ic# ma7es it faster' ollbac7 is not possible'
2) What is a I (e ? T38es o, I (e es? o& a 3 %!/stere( i (e es a ( o *%!/stere( i (e es %reate( o a ta"!e? Fenerall& SQL Server e4amines (table scan ever& ro" in t#e table to satisf&
t#e H$er& res$lts' nde4 is a p#&sical str$ct$re containing pointers to t#edata "#ic# is $sed for retrieving data more H$ic7l& and improves t#e H$er& performance ' C!/stere( I (e ?- Onl& one ,l$stered inde4 can create on a Table' 9#en "e create a cl$stered inde4 on a table! all t#e ro"s in t#e table are stored in t#e order of t#e cl$stered inde4 7e&' @o *%!/stere( i (e ?- 2> 3on-,l$stered inde4es can create on a Table' 3on-cl$stered inde4es are stored as A-Tree str$ct$res "it# t#e leaf level nodes #aving t#e inde4 7e& and it6s ro" locator'
#) o& %a &e re"/i!( a I (e ?
A& $sing A,, A . 3 .
+) What s the (i$ere %e "et&ee a 8ri ar3 =e3 a ( a / i /e =e3? Aot# primar& 7e& and $niH$e 7e& enforces $niH$eness of t#e col$mn on "#ic# t#e& are de<ned'
S !
1 Primar& 7e& creates a cl$stered inde4
;niH$e 7e& creates a non- cl$stered inde4
2 Primar& e& doesn6t allo" 3$lls ;niH$e 7e& allo"s one 3$ll onl&
) What is Store( Pro%e(/re? / stored proced$re is a pre-compiled SQL statements t#at are stored in Sever database to performing a tas7' / single proced$re can be $sed over t#e net"or7 b& several clients $sing diWerent inp$t data' /nd "#en t#e proced$re is modi<ed! all clients a$tomaticall& get t#e ne" version'
A(va ta.es ?-1 Stored proced$re can red$ce net"or7 traGc beca$se H$eries e4ec$ted as a batc#'
8/20/2019 DBA Iq Faq-praveen
2 mproving t#e performance beca$se t#e SPs are pre-compiled' = Stored proced$res provide better sec$rit& to &o$r data > .asil& modif& t#e SPs "#en b$siness r$les c#ange'
-) What is ser De6 e( F/ %tio ? T38es o, DFs? ;ser- e<ned E$nctions t#at allo" &o$ to de<ne &o$r o"n T-SQL f$nctions t#at can accept ero or more parameters and ret$rn a single scalar data val$e or a table data t&pe' T#ere are t#ree t&pes of ; Es are available in SQL Server 2005' a S%a!ar Va!/e( DFs ?- / scalar-val$ed ; E accepts parameters and
ret$rns a single scalar data t&pes (Te4t! nte4t! image ' b Ta"!e Va!/e( DFs ?- / table-val$ed ; E is a f$nction t#at accepts
parameters and ret$rns t#e res$lts in t#e form of a table'
0) What are the (i$ere %es "et&ee Store( Pro%e(/re a ( ser
De6 e( F/ %tio ?S !
ser De6 e( F/ %tio s Store( Pro%e(/res
1 E$nctions are compiled and e4ec$ted at r$n time'
Stored proced$res are stored in parsed and compiled format in t#e database'
2 E$nctions cannot aWect t#e state of t#e database "#ic# means "e cannot perform insert!delete!$pdate and create operations on t#e database'
Stored Proced$res can aWect t#e state of t#e database b& $sing insert! delete! $pdate and create operations'
= E$nctions are basicall& $sed to comp$te val$es' 9e passes some parameters to f$nctions as inp$t and t#en it performs some operations on t#e parameter and ret$rn o$tp$t'
Stored proced$res are basicall& $sed to process t#e tas7'
> E$nction can not c#ange server
environment and o$r operatings&stem environment'
Stored proced$res can
c#ange server environmentand o$r operating s&stem environment
5 E$nctions can not be invo7ed from SQL Statements' .4ec$te' S.L.,T
operating s&stem can be invo7ed from SQL Statements' .4ec$te' S.L.,T
+ E$nctions can r$n an e4ec$table <le from SQL S.L.,T or an action H$er&'
operating s&stem $se .4ec$te or .4ec to r$n
4) What is a Tri..er? What are the tri..er o(e!s are avai!a"!e i SQL Server 2'' ?
8/20/2019 DBA Iq Faq-praveen
/ trigger is a set of T-SQL Statements stored permanentl& in t#e atabase and a$tomaticall& <red "#en an event occ$rs' T#e& are $sed to impose $ser de<ned restrictions or b$siness r$les and also provides #ig# sec$rit& on
atabaseC tables' T#ere are t"o t&pes of trigger models are available in SQL Server 2005 D7L Tri..ers ?- ML triggers created on ML statements li7e nsert! ;pdate and elete of atabase ob8ects DDL Tri..ers ?- L triggers created on L statements li7e ,reate! /lter and rop of A ob8ects or A'
5) T38es o, Tri..ers? T#ere are t"o t&pes of triggers -) A,ter Tri..ers ?- /fter Triggers "ill <res after t#e data is inserted into
t#e table' T#e t&pical $se for an /fter trigger is to log t#e action to an /$dit or logging table
0) Be,ore Tri..ers ?- Aefore triggers "ill <re before t#e data is insertedinto t#e table' @ote ?- ML triggers <res before or after iss$e! L triggers <res after t#e iss$e'
1') What is a Vie& a ( a(va ta.es o, Vie&s? / vie" is a pre-de<ned SQL Statements t#at t#e A engine e4ec$tes and retrieves d&namicall&' / standard vie" acts as a virt$al table based on t#e res$lt set of a select statement' T#e <elds in a vie" are <elds from one or more real tables or anot#er vie"s' A(va ta.es ?-
1 To restrict t#e $sers to speci<c ro"s : col$mns and #ide t#e col$mns "it# sensitive data
2 ;ser friendl& names can be provided instead of base table col$mn names = EreH$entl& $sed comple4 @oins! Q$eries and ;nions can be coded once as a
ie" and ie" can be referenced for simplicit& and consistenc& of coding' > /ggregate information s$c# as S$ms! ,o$nts! /vg and so on can be
calc$lated in a vie" to simplif& coding "#en t#ose aggregation information "ill be referenced m$ltiple times'
5 ie"s can be $sed for ata sec$rit&! allo"ing $sers access certain data "it#o$t granted permissions to directl& access t#e base tables'
11) T38es o, Vie&s? E 8!ai a"o/t I (e e( Vie&? T#ere are t"o t&pes of ie"s 1 Standard ie" 2 nde4ed ie"s' /n inde4ed ie" (materiali ed vie" is li7e a standard vie"! and it #as a $niH$e cl$stered inde4 created on it' t stored p#&sicall& 8$st li7e a table' A(va ta.e ?- nde4ed vie"s "or7s best for H$eries t#at aggregates man& ro"s or #ave 8oins t#at ca$se response time of t#e standard vie" to be slo"'
12) What is the (i$ere %e "et&ee a Lo%a! a ( a ;!o"a! te 8orar3
Lo%a! te 8orar3 ta"!e ?- t e4ists onl& for t#e d$ration of a connection or! if de<ned inside a compo$nd statement! for t#e d$ration of t#e compo$nd statement' ;!o"a! te 8orar3 ta"!e ?- remains in t#e database permanentl&! b$t t#e ro"s e4ist onl& "it#in a given connection' 9#en connection is closed! t#e data in t#e global temporar& table disappears' No"ever! t#e table de<nition remains "it# t#e database for access "#en database is opened ne4t time'
1#) What is PRI7AR E ? / P M/ D .D constraint is a $niH$e identi<er for a ro" "it#in a database table' .ver& table s#o$ld #ave a primar& 7e& constraint to $niH$el& identif& eac# ro" and onl& one primar& 7e& constraint can be created for eac# table'
T#e primar& 7e& constraints are $sed to enforce entit& integrit&'
1+) What is @IQ E E %o strai t?
/ ;3 Q;. constraint enforces t#e $niH$eness of t#e val$es in a set of col$mns! so no d$plicate val$es are entered' T#e $niH$e 7e& constraints are $sed to enforce entit& integrit& as t#e primar& 7e& constraints'
1 ) What is FOREI;@ E ? / EO . F3 .D constraint prevents an& actions t#at "o$ld destro& lin7s bet"een tables "it# t#e corresponding data val$es' / foreign 7e& in one table points to a primar& 7e& in anot#er table' Eoreign 7e&s prevent actions t#at "o$ld leave ro"s "it# foreign 7e& val$es "#en t#ere are no primar& 7e&s "it# t#at val$e' T#e foreign 7e& constraints are $sed to enforce referential integrit&'
1-) What is C EC Co strai t? / ,N., constraint is $sed to limit t#e val$es t#at can be placed in a col$mn' T#e c#ec7 constraints are $sed to enforce domain integrit&'
10) What is @OT @ LL Co strai t? / 3OT 3;LL constraint enforces t#at t#e col$mn "ill not accept n$ll val$es'