You are on page 1of 91

How do you set the session mode parameters in BTEQ?

Answer
.set session transaction ANSI /* this is to set ANSI mode */
.set session transaction BTET /* this is to set Teradata transaction mode */
These commands have to e entered e!ore "o##in# to the session
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
%hat is the command in BTEQ to chec& !or session settin#s ?
Answer
The BTEQ .SH'% ('NT)'* command disp"ays BTEQ settin#s.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
How do you sumit te+ script ,atch mode-?
Answer
.. Start the BTEQ/ y typin# BTEQ
0. Enter the !o""owin# command
.run 1"e $ BTEQScript.t+
')
.. Bte+ 2 BTEQScript.t+
BTEQScript.t+ contains !o""owin#
."o#on .03.4.4../dc/ dc5
se" top .4 * !rom dc.ta"es5
.+uit
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Is *i&e comparision case6sensitive in Teradata?
Answer
*I7E operator is not case sensitive in Teradata.
(onsider the !o""owin# e8amp"e
Se"ect 9:name !rom emp"oyee where 9:name "i&e ;<='<; 5
The !o""owi# +uery wi"" pic& va"ues matchin! with ;='; and ;>o; as we""/ since
teradata is not case6sensitive
To overcome this pro"em/ a new !unction ca""ed ?(ASES@E(I9I(? is used in
TE)AAATA as !o""ows
Se"ect 9:name !rom emp"oyee where 9:name ,(ASES@E(I9I(- "i&e ;<='<; 5
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
%hat does A)'@ ta"e command do?
It de"etes a"" data in emp:AATA
)emoves the emp:AATA de1niation !rom the data dictionary
)emoves a"" e8p"icit access ri#hts on the ta"e
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
How do you set de!au"t date settin# in BTEQ?
Answer
There are two de!au"t date settin# in BTEQ. They have to e set a!ter
"o##in# on to the session
They are
Set session date!orm $ ANSIAATE5 /*!ormat is yyyy6mm6dd */
Set session date!orm $ inte#erdate5 /* !ormat is yy/mm/dd 6teradata date
!ormat */
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
AiBerence etween Inner >oin and outer >oin?
An inner >oin #ets data !rom oth ta"es where the speci1ed data e8ists in
oth
ta"es.
An outer >oin #ets data !rom the source ta"e at a"" times/ and returns data
!rom
the outer >oined ta"e 'N*C i! it matches the criteria.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
%hat is mu"ti Insert?
Insertin# data records into the ta"e usin# mu"tip"e insert statements.
@uttin# a Semi co"on in !ront o! the &ey word INSE)T in the ne8t statement
rather than
Terminatin# the 1rst statement with a semi co"on achieves it.
Insert into Sa"es Dse"ect * !rom customerE
5 Insert into *oan Dse"ect * !rom customerE5
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$
How to 1nd dup"icates in a ta"e?
Froup y those 1e"ds and se"ect id/ count,*- !rom ta"e #roup y id havin#
count
,*- G .
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$
How do you see a AA* !or an e8istin# ta"e?
By usin# show ta"e command.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$
%hich is more eHcient F)'I@ BC or AISTIN(T to 1nd dup"icates?
%ith more dup"icates F)'I@ BC is more eHcient/ i! on"y a !ew dup"icates
e8ist
AISTIN(T is more eHcient.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$
Synta8 !or (ASE %HEN statement?
(ASE va"ue:e8pression:. %HEN va"ue:e8pression:n THEN
sca"ar:e8pression:n
ENA5
Teradata Interview questions - Part 6
%hat is a Sparse Inde8?
Answer:
Sparse =oin Inde8es are a type o! =oin Inde8 which contains a %HE)E c"ause
that reduces the numer o! rows which wou"d otherwise e inc"uded in the
inde8. A"" types o! >oin inde8es/ inc"udin# sin#"e ta"e/ mu"tita"e/ simp"e or
a##re#ate can e sparse.
AiBerence etween Stored @rocedure and Jacro?
Answer:
SP:
It does not return rows to the user.
It has to use cursors to !etch mu"tip"e rows
It used Inout/'ut to send va"ues to user
It (ontains comprehensive S@*
It is stored in AATABASE or ISE) @E)J
A stored procedure a"so provides output/Input capai"ities
MacrosK
It returns set o! rows to the user.
It is stored in AB( @E)J space
A macro that a""ows on"y input va"ues
How do you e8ecute the #iven SQ* statement repeated"y in BTEQ?
Answer:
Se"ect top .* !rom dataase.ta"e.5
$n
Here ?$nE is to run the previous s+" statement/ ?n? numer o! times.
%hat are types o! @A)TITI'N @)IJA)C INAEL ,@@I- in Teradata?
Answer:
.. @artition y (ASE
CREATE TABLE ')AE):Ta"e
,
')A:numer inte#er NOT NLL/
customer:numer inte#er NOT NLL/
order:date date /
order:tota" inte#er
-
PRIMAR! IN"E# ,customer:numer-
PARTITION B! case. ,
order:tota" 2 .4444 /
order:tota" 2 04444 /
order:tota" 2 M4444/
NO CASE OR N$NO%N - 5
0. @artition y )an#e 6 e8amp"e usin# date ran#e
CREATE TABLE ')AE):Ta"e
,
')A:numer inte#er NOT NLL/
customer:numer inte#er NOT NLL/
order:date date /
order:tota" inte#er
-
PRIMAR! IN"E# ,customer:numer-
PARTITION B! ran#e. ,
'rder:date BET%EEN date ;04.464.64.; AN" date ;04.46.06
4.;
EAC& interva" ;.; month /
NO RAN'E
OR N$NO%N-5
P(S:I! we use N' )ANFE or N' (ASE 6 then a"" va"ues not in this ran#e wi""
e in a sin#"e partition.
I! we speci!y IN7N'%N/ then a"" nu"" va"ues wi"" e p"aced in this partition
(an we de1ne @A)TITI'N @)IJA)C INAEL ,@@I- on a @rimary Inde8 co"umn in
Ta"e? E8p"ain %hy?
Answer:
@@I cannot e de1ned on @I co"umn in Ta"e. Since @I is used to "ocate an
AJ@ and store the data ased on HASH va"ue ,)'% IA - it cannot e used as
@@I co"umn.
In case o! @@I / The data stored in AJ@;s are @artitioned ased on @@I co"umn
a!ter they are row hashed ,RO% $E! $ )'% IA N@@I va"ue -
%hat is (ross =oin?
Answer:
It is a Teradata speci1ed =oin/ which is used as e+uiva"ent to product >oin.
There is no D'nE c"ause in case o! ()'SS >oin
SELECT EJ@.ename / A@T.Aname
)ROM emp"oyee EJ@
CROSS *OIN
Aepartment A@T
%&ERE
EJp.deptno $ A@T.depto 5
%hat does S*EE@ !unction does in 9ast "oad?
Answer
The S*EE@ command speci1es the amount minutes to wait e!ore retryin# to
"o#on and esta"ish a"" sessions.
S"eep command can e used with a"" "oad uti"ities not on"y !ast"oad.
This situation can occur i! a"" o! the "oader s"ots are used or i! the numer o!
re+uested sessions is not avai"a"e. The de!au"t va"ue is O minutes. I! tenacity
was set to 0 hours and s"eep .4 minutes/ S"eep command wi"" try to "o#on !or
every .4 minutes up to 0 hours duration.
%hat is TENA(ITC? %hat is its de!au"t va"ue?
Answer
TENA(ITC speci1es the amount o! time in hours/ to retry to otain a "oader
s"ot or to esta"ish a"" re+uested sessions to "o#on. The de!au"t !or 9ast *oad
is Dno tenacityE/ meanin# that it wi"" not retry at a"". I! severa" 9ast*oad >os
are e8ecuted at the same time/ we recommend settin# the TENA(ITC to P/
meanin# that the system wi"" continue tryin# to "o#on !or the numer o!
sessions re+uested !or up to !our hours.
How to s&ip .
st
record whi"e usin# Bte+ IJ@')T?
Answer:
By usin# S7I@$. 5 / we can s&ip 1rst record.
(i+,ort in-.e/0-.ena+e12 s3i,/45
How many types o! Inde8 are present in teradata?
Answer:
There are 6 diBerent indices present in Teradata
.. @rimary Inde8
a.Ini+ue primary inde8
. non Ini+ue primary inde8
0. Secondary Inde8
a. Ini+ue Secondary inde8
. non Ini+ue Secondary inde8
M. @artitioned @rimary Inde8
a. (ase partition ,e8. a#e/ sa"ary...-
. ran#e partition , e8. date-
P. =oin inde8
a. Sin#"e ta"e >oin inde8
. mu"tip"e ta"e >oin inde8
c. Sparse =oin inde8 , constraint app"ied on >oin inde8 in where c"ause-
Q. Hash inde8
%hich is !aster R Ju"ti*oad de"ete or Ae"ete command?
Answer
Ju"ti*oad de"ete is !aster then norma" Ae"ete command/ since the de"etion
happens in data "oc&s o! OP7ytes/ where as de"ete command de"etes data
row y row. Transient >ourna" maintains entries on"y !or Ae"ete command
since Teradata uti"ities doesnSt support Transient >ourna" "oadin#.
How to S&ip or Fet 1rst and *ast )ecord !rom 9"at 9i"e throu#h Ju"ti*oad?
Answer
In .IJ@')T command in J"oad we have a option to #ive record no. !rom
which processin# shou"d e#in. i.e. T9)'J mS TmS is a "o#ica" record numer/
as an inte#er/ o! the record in the identi1ed data source where processin# is
to e#in. Cou can mention SmS as 0 and processin# wi"" start !rom second
record.
TH)I & and 9') n are two options in the same J"oad command/ !unctions
same towards the end o! the processin#.
Addin# to the aove/ i! !rom n?start record? and !or n ?stop record? are not
mentioned/ m"oad considers records !rom start ti"" the end o! the 1"e.
%hat do Hi#h con1dence/ *ow con1dence and No con1dence mean in
EL@*AIN p"an?
Answer
E8p"ain #ives the e8ecution strate#y means what are the diBerent steps that
the +uery wi"" #o throu#h.
HIFH ('N9IAEN(EK Statistics are co""ected.
*'% ('N9IAEN(EK Statistics are not co""ected. But the where condition is
havin# the condition on inde8ed co"umn. Then estimations can e ased on
samp"in#.
N' ('N9IAEN(EK Statistics are not co""ected and the condition is on non
inde8ed co"umn.
%hat is the de!au"t >oin strate#y in Teradata???
Answer
7 4
The Teradata (ost ased optimiUer wi"" decide the >oin strate#y ased on the
optimum path. The common strate#ies !o""owed are !rom Jer#e/ Hash V
Nested =oin
Answer
7 8
Three strate#ies !o""owed y optimiUer areK
.. Aup"ication o! rows o! one ta"e to every amp
66G This one is opted y optimiUer when the non6@I co"umn is on a sma""
ta"e.
0. )edistriution o! the non @I rows o! the ta"e to the amp containin# the
matchin# @I row amp.
66G This one is opted when the ta"es are "ar#e. The non @I co"umn is in one
ta"e is redistriuted to the amp containin# the matchin# @I.
M. )edistriute oth the rows o! the ta"e y hash va"ues.
66G This is chosen when the >oin is on a co"umn that is not the @I in either
ta"e. This wi"" re+uire the most spoo" space.
(an we ta&e co""ect stats on Aerived Ta"es and Wo"ati"e ta"es and
Temporary ta"es?
%hat is F"oa" Temporary ta"e?
%hat is the use o! this F"oa" Temporary ta"e?
Answer
.. No !or vo"ati"e and derived ta"es and yes !or #"oa" ta"es.
0. F"oa" ta"es are temp ta"es "i&e vo"ati"e ta"es ut un"i&e vo"ati"e ta"es/
their de1nitions are retained in dd.
M. It is used whenever there is a need !or a temporary ta"e with same ta"e
de1nition !or a"" users.
How to hand"e nu""s in Teradata???
How many co"umns can e there in a ta"e???
How to 1nd avera#e sa" with out usin# av# !unction????
Answer
.. Ise Ueroi!nu""/ nu""i!Uero in se"ect and NI** in insert direct"y.
0. 0QO co"umns ma8 per ta"e.
M. %ithout usin# ?av#? we can 1nd the av# sa"ary y usin# sum ,sa"-/count
,sa"-5
se" sum,sa"-/count,sa"- as av#sa" !rom ta"ename
Is +u.ti insert ANSI standard9
No.
4:(I a+ u,datin; a ta<.e in Bteq( It =as to u,date a .ar;e nu+<er o>
rows2
so it?s rea..@ s.ow( %=at do @ou su;;est9
In Teradata it is not recommended to update more than . mi""ion rows due to
>ourna" space pro"ems/ i! it is "ess than that and itSs s"ow in the Bte+/ you
mi#ht
want to add co""ect statistics statement e!ore the update statement.
46(Is it necessar@ to add ABIT? state+ent a>ter a Bteq quer@ w=en I
a+
ca..in; it in a niC environ+ent9
Not necessary ut it is #ood to add a QIIT statement a!ter a +uery.
T=ere is a co.u+n wit= date in it( I> I want to ;et Dust +ont= =ow It
can
<e done9 Can I use su< strin;9
Su strin# is used with char 1e"ds. So it cannot e used. To e8tract month
!rom a
date co"umn/ e8 se"ect e8tract ,month !rom 2co"umn nameG-. Same thin#
!or
(on1dentia" property o! Fantec (orporation.day !or date/year !or year
year or day. 'r hour or minutes i! itSs a time stamp ,se"ect e8tract ,minute
!rom co"umn name-.
M@ ta<.e ;ot .oc3ed durin; MLOA" due to a >ai.ed Do<( %=at do I do
to
,er>or+ ot=er o,erations on it9
Isin# )E*EASE J*'AA. It removes access "oc&s !rom the tar#et ta"es in
Teradata. It must e entered !rom BTEQ and not !rom Ju"ti*oad.
To proceed/ you can do )E*EASE J*'AA 2ta"e nameG
%=ic= is +ore eEcient 'ROP B! or "ISTINCT to -nd du,.icates9
%ith more dup"icates F)'I@ BC is more eHcient/ i! on"y a !ew dup"icates
e8ist
AISTIN(T is more eHcient.
What is differnce between Error code and Error Level in Bteq
Error code is the code for the error for ex 3807 is the error code for the error "object does not
exist"
To know the error codes t!e
select " fro# dbc$error#s%s
in the &'er#an
Error level is the severit set for the corres!ondin% error code
if error level is
0( )'ccess
*( Warnin%
8( +ser Error
,-( .atal error
,/( T!ical Error
What is a !se'do ke0 What is its 'se000
1ollect stats +ses
The 2!ti#i3er !lans an exec'tion strate% for ever )&L q'er s'b#itted to it$ We have also
seen that the exec'tion strate% for an q'er #a be s'bject to chan%e de!endin% on vario's
factors$ .or the 2!ti#i3er to consistentl choose the o!ti#'# strate%4 it #'st be !rovided with
reliable4 co#!lete4 and c'rrent de#o%ra!hic infor#ation re%ardin% all of these factors$ The best
wa to ass're that the 2!ti#i3er has all the infor#ation it needs to %enerate o!ti#'#
exec'tion strate%ies
is to 12LLE1T )T5T6)T61)$
()tatistics tell the 2!ti#i3er how #an rows7 val'e there are$
8 The 2!ti#i3er 'ses statistics to !lan the best wa to access data$
8 9a i#!rove !erfor#ance of co#!lex q'eries and joins$
8 :+)6 Bit 9a!!in% req'ires collected statistics$
8 ;el!f'l in accessin% a col'#n or index with 'neven val'e distrib'tion$
8 )tale statistics #a #islead the 2!ti#i3er into !oor decisions$
8 )tatistics re#ain valid across a reconfi%'ration of the sste#$
8 12LLE1T is reso'rce intensive and sho'ld be done d'rin% off ho'rs$
What is the 9axi#'# n'#ber of volatile tables that can be created0
/* volatile tables for a 'ser in a session$
Wh .L25< does not s'!!ort #'ltiset tables00
.load will allow #'ltiset table$ B't there is no advanta%e of loadin% #'ltiset table 'sin% fload4
bec'ase fload does not insert d'!licate rows$ 6f we tr to load #'ltiset table 'sin% fload with
d'!licate rows4 the fload inserts distinct rows into the tar%et table and the d'!licate row
co'nt dis!laed 'nder second error table$
.astload 'tilit does not s'!!ort d'!licate rows$
,$)ince 9) table s'!!orts d'! rows fastload cannot load 9) table$
-$=estart lo%ic is one of the reason$ .astload is one of the 'tilit which loads data in
blocks>/*?@$ <'rin% restart .astload sends so#e of the rows for the second ti#e which
occ'r after a check!oint$ <'e to this .astload rejects d'!licates$
.or exa#!le consider -0 rows to be loaded in a table$ .L 'tilit is 'sed to load the table and ck!t
is A rows$ 6f restart occ'rs after 7th row .L #a send / and 7th to 59Bs d'rin% the restart$ This
records wo'ld be considered as d'!licates and rejected$
what is the difference between filter and ro'ter trans#issions
in filter4it is not !ossible to take exce!tion date4b't it is !ossible in ro'ter$one condition is
!ossible in filter b't in ro'ter #ore no$ of col'#ns are !ossible$
5 .ilter transfor#ation tests data for one condition and dro!s the rows of data that do not #eet
the condition$ ;owever4 a =o'ter transfor#ation tests data for one or #ore conditions and %ives
o' the o!tion to ro'te rows of data that do not #eet an of the conditions to a defa'lt o't!'t
%ro'!$


we have two tables e#!4de!t$e#! has eno4ena#e4sal and de!t has de!tno4dna#e$how to find
#axsal of each de!t wise$which join 'sed for joinin%$
e#! table havin% de!nto and de!t table contains de!tno then onl we can join the two table and
find o't #ax sal de!t wise
q'erC
select e$de!tno4d$dna#e4#ax>e$sal@ fro# e#! e4de!t d
where d$de!tnoDe$de!tno
%ro'! b e$de!tno4d$dna#e
select de!no4#ax>sal@
fro# e#! e4de!t d
where e$de!tnoDd$de!tno
%ro'! b de!tnoE
)ince there is no co##on col'#n4 it #a not be !ossible to join two tables$ if de!tno is in e#!
table4 correlated q'er can be 'sed
e#!
eno ena#e sal de!tno
, 'va ,0 tn,
- 'v, -0 tn-
3 'v3 30 tn,
select " fro# e#! as e,
where sal in
>sel #ax>sal@ fro# e#! as e-
where e,$de!tnoDe-$de!tno@E
-$ while r'nnin% #load if the job is aborted7failed at an !hase what we have to look after to r'n
the job s'ccessf'll0
release #load4 dro! the lo% table4work table4error table and s'b#it the #load if the table needs to
be loaded fro# first$
1heck the lo% file to know the exact fail're$ .ix it4 do the #lod clean'! and rer'n the job$
;ow to co! , #illion records fro# one <B to another4 Which is effective inter#s of
!erfor#ance0
6n this case4 write a fastex!ort to ex!ort the data and a fastload7#load scri!t to load it to other
database$

Fo' can 'se :B5=1 !rocess for co! data fro# tables in one database to another table in
different database

can anone tell #e how #an t!es of )kew exists0 whats the difference between a#! skew4data
skew4c!' skew4 io skew4 delta a#! c!' 0
;ow #an t!es of )kew exists0
6f o' 'tili3ed 'neq'all T< reso'rces>1B+459B4624<isk and etc@ this is called skew exists$
9ajor are 3 t!e of skews >1B+ skew459B7<ata skew4 62 )kew@$
(<ata skew0
When data is not distrib'ited eq'all on all 59Bs$
(1!' skew0
Who is takin%7cons'#in% #ore 1B+ called c!' skew$
(62 skew0
Who !erfor# #ore 62 2!eration$ called 62 )kew$
G26: 6:<EHC
(((((((((((
Goin 6ndex is nothin% b't !re(joinin% - or #ore tables or views which are co##onl joined in
order to red'ce the joinin% overhead$ )o teradata 'ses the join index instead of resolvin% the
joins in the !artici!atin% base tables$The increase the efficienc and !erfor#ance of join
q'eries$ The can have different !ri#ar indexes than the base tables and also are a'to#aticall
'!dated as and when the base rows are '!dated$ the can have re!eatin% val'es$
There are 3 t!es of join indexesC
,@)in%le table join index ( here the rows are distrib'ted based on the forei%n ke hash val'e of
the base table$
-@ 9'lti table join index ( joinin% two tables$
3@ 5%%re%ate join index ( !erfor#in% the a%%re%ates b't onl s'# and co'nt$
The followin% exa#!le shows how to create table and insert data witho't d'!licate rows fro#
existin% tableC
1=E5TE T5BLE :2<+B) 5)
>
)ELE1T " .=29 <e!art#ents
+:62:
)ELE1T " .=29 <e!art#ents
@
W6T; <5T5E
;ow to )ki! or Iet first and Last =ecord fro# .lat .ile thro'%h 9'ltiLoad and TB+9B +tilit0
What is filler in Teradata0
What is the !rocess to restart the #'ltiload if it fails0
6f 9load failed in the 5cq'isition !hase j'st rer'n the job$6f 9load failed in 5!!lication BhaseC
a@ Tr to dro! error tables4 work tables4 lo% tables4 release 9load if req'ired and s'b#it the job
fro# $Be%in 6#!ort onwards$
b@ if 'r table is fallback !rotected ' need to #ake s're 'n fallback and 'se =ELE5)E 9L25<
6: 5BBLF sql$
Then res'b#it the job$
9odification to 5nswerJ3 !laced above$
9load fails in a!!lication !haseC Then we cannot access the table$
,$ The sol'tion is we need to restart the #load job or dro! the ori%inal table and worktable and
lo%table and error tables$
-$ 6f we re#ove worktables4 errortables and lo%tables then we can restart the #load job$ 6f we tr
to restart then it %ives the error #essa%es sain% worktable is #issin% for the table$ Even release
#load also doesnKt work$
-$ 6f we donKt re#oveC Then if we restart #load job4 then it will be fine and start fro# the
check!oint4 of the last block that have '!dated to disk$

-$ Which +tilit 'sed to co! a table and restore it to another database0
5rchive =ecover
The Iiven below4 which tool sho'ld o' 'se to collect and anal3e database !erfor#ance0
Tearadata #ana%er
Batch !rocess block level loadin% are !erfor#ed a%ainst !o!'lated tables b which 'tilit
9'ltiload
Teradata 6ndex wi3ard 'sed for to reco##end secondar indexes for a table
Iiven below4 What is the #axi#'# level of data !rotection
=56< , and .allback
%=at?s t=e diFerence <etween TIMESTAMP GHI and TIMESTAMP G6I9
TIJESTAJ@ ,4- is (HA) ,.X- and TIJESTAJ@ ,O- is (HA) ,0O-
Everythin# is same e8cept that TIJESTAJ@ ,O- has microseconds too.
&ave @ou used ,rocedures9
No. I have not used procedures. But I have e8pertise &now"ed#e writin#
procedures. Jy company have not encoura#ed me to write procedures
ecause it ecomes sin#"e AJ@ operation/ as such uses "ot o! resources and
e8pensive in terms o! resource and time.
&ow to -nd No( o> Records ,resent in Eac= AMP or a Node >or a
;iven Ta<.e t=rou;= SBL9
)el ;5);59B>;5);B+1?ET>;5);=2W>B=695=FL6:<EHL12L+9:)@@@
5) 59BL:24
12+:T>"@
.ro# <5T5B5)E:59E$T5BLEL:59E
I=2+B BF ,E
Hello all, There is a table with 4 columns in that 3 columns has been already loaded with 5
million records.4th column is empty,Now I have got 5 million records data which has to be
loaded into *th col'#n$;ow can 6 load this data fastl in to the *th col'#n with o't 'sin% '!date
Ju"ti"oad
AiB /w v0rQ and v0rO ?
IN A TAB*E (AN %E ISE @)IJA)C 7EC IN 'NE ('*IJN ANA IN AN'THE)
('*IJN B'TH INIQIE ANA N'T NI** ('NST)AINS.I9 CES H'%?@*Y FIWE
JE A ELAJ@*E.
Fenera""y how many node systems wi"" e used y the c"ient. 0. %hi"e
runnin# m"oad i! the >o is aorted/!ai"ed at any phase what we have to "oo&
a!ter to run the >o success!u""y? M.i wanted to &now how to write the !ast
"oad script !or ta"e creation as we"" as ta"e "oadin# in a sin#"e script?
,@ 6t de!ends on the req'ire#ent$ Ienerall aro'nd ,0 node sste# will be a #oderate to hi%h
data ware ho'se environ#ents$
-@ 1heck the lo% file to know the exact fail're$ .ix it4 do the #load clean'! and rer'n the job$
3@ )!ecif the table creation ste! in the be%innin% of the scri!t before the act'al fastload
co##ands starts$
,$ 5s said above4 the req'ire#ent drives the no of nodes to be connected$ B't4 for #illions of
data4 %enerall4 ,0 nodes #a be 'sed
-$release #load4 dro! the lo% table4work table4error table and s'b#it the #load if the table needs
to be loaded fro# first$
3$Lo% onto Teradata4<efinin% the Teradata table that o' want to load >tar%et table@4<efinin% the
6:B+T data file4
Tellin% the sste# to start loadin%$
What is the process to restart the multiload i it ails!
The above ans is onl when the 9L25< failed in acq'isition !hase
To release lock in a!!lication !hase fail're in 9L25<
=ELE5)E 9L25< MTable :a#eN $6: 5BBLFE
%hy does varchar occupy 0 e8tra ytes?
Answer
The two ytes are !or the numer o! ytes !or the inary "en#th o! the 1e"d.
It stores the e8act no o! characters stored in varchar
%=at is t=e diFerence <etween start sc=e+a and )s.d+?
Answer
Star Sc=e+a
66G Aemora"iUed !or +uery per!ormance
66G A star schema has one 9act ta"es and many dimensiona" ta"es to store
the re"ated.
)SL"M ,)inancia" Services Lo#ica" "ata Mode"-
66G Mrd norma" !orm
66G@roposed and desi#ned y N() to cater the needs o! 1nancia" sectors/
especia""y !or the Ban&in# domain.
66G It has many 9act ta"es and dimension ta"es.
66G The 9S*AJ can e customiUed to cater to an&;s speci1c needs.
E8. The ma>or !act ta"es inc"ude @arty ,(ustomers o! the an&-/ @roduct
,Services oBered y the an&-/ Event ,An event occurred e8K An ATJ
transaction-/ A#reement ,A dea" etween
the party and the an& !or a product- / etc..
Can @ou .oad +u.ti,.e data -.es >or sa+e tar;et ta<.e usin;
)ast.oad9
Answer:
Ces/ we can *oad a ta"e usin# mu"tip"e data1"es in 9ast"oad.
Be!ore #ivin# ?end "oadin#? statement user can de1ne 1"e path and use
insert s+" !or mu"tip"e source 1"es and #ive ?end "oadin#? statement at the
end
EC,.ain t@,es o> re-distri<ution o> data =a,,enin; >or Doinin; o>
co.u+ns >ro+ two ta<.es
(ase . 6 @.I $ @.I >oins
(ase 0 6 @.I $ non Inde8 >oins
(ase M 6 non Inde8 $ non Inde8 >oins
Answer:
(ase. 6 there is no redistriution o! data over amp;s. Since amp "oca" >oins
happen as data are present in same AJ@ and need not e re6distriuted.
These types o! >oins on uni+ue primary inde8 are very !ast.
(ase0 6 data !rom second ta"e wi"" e re6distriuted on a"" amps since >oins
are happenin# on @I vs. non Inde8 co"umn. Idea" scenario is when sma"" ta"e
is redistriuted to e >oined with "ar#e ta"e records on same amp
caseM 6 data !rom oth the ta"es are redistriuted on a"" AJ@s. This is one
o! the "on#est processin# +ueries / (are shou"d e ta&en to see that stats are
co""ected on these co"umns
&ow to s3i, t=e =eader row in t=e >ast.oad scri,t9
)E(')A 05 /* this s&ips 1rst record in the source 1"e */
AE9INE ...
&ow to -nd out .ist o> indeCes in Teradata9
IndeCT@,
e "escri,tion
@ Nonpartitioned @rimary
Q @artitioned @rimary
S Secondary
= >oin inde8
N hash inde8
7 primary &ey
I uni+ue constraint
W va"ue ordered secondary
H hash ordered A** coverin# secondary
'
va"ued ordered A** coverin#
secondary
I
orderin# co"umn o! a composite
secondary inde8
J Ju"ti co"umn statistics
A Aerived co"umn partition statistics
. 1e"d. co"umn o! a >oin or hash inde8
0 1e"d0 co"umn o! a >oin or hash inde8
SELECT
dataasename/ ta"ename/ co"umnname/ inde8type/ inde8numer/
inde8name
)ROM
dc.indices
OR"ER B!
dataasename/ ta"ename/ inde8numer5
&ow to identi>@ PPI co.u+ns9
Answer:
Se"ect dataasename / ta"ename / co"umnposition /co"umnname !rom
dc.indices
where inde8type $;Q;
order y . /0/M 5
%=at are t=e scenarios in w=ic= )u.. Ta<.e Scans occurs9
.. The where c"ause in SE*E(T statement does not use either primary inde8
or secondary inde8
0. SQ* Statement which uses a partia" va"ue ,"i&e or not "i&e-/ in the %HE)E
statement.
M. SQ* Statement which does not contain where c"ause.
P. SQ* statement usin# ran#e in where c"ause. E8. ,co". G P4 or co". 2
$.4444-

%=at are "iFerences <etween Teradata and ANSI Session +odes in
Teradata9
Answer:
TE)AAATA J'AE
6666666666666
.. (omparison is not (ase sensitive
0. (reate ta"e are de!au"t to SET ta"es
M. Each transaction is committed imp"icit"y
P. Supports a"" Teradata commands
Q. It !o""ows BTET ,Be#in and End Transaction- Jode
ANSI J'AE
6666666666666
.. (omparison is (ASE sensitive
0. (reate ta"e are de!au"t to JI*TISET ta"es
M. Each transaction has to e committed e8p"icit"y
P. Aoes not support a"" Teradata commands
Q. It does not !o""ow BTET Jode
&ow do @ou create +ateria.iJed view in Teradata9
Answer:
There is no such thin# as a ?materia"iUed view? in Teradata. The e+uiva"ent in
Teradata wou"d e a >oin inde8 ,or a##re#ate inde8- with a correspondin#
view put on top o! it. The command to create one is ?()EATE ='IN INAEL...
,"ots o! options-?.
=oin indices are maintained when the data is maintained. They cannot e
accessed direct"y/ ut are invo&ed when the optimiUer determines it is
ene1cia". Even thou#h you cannot invo&e a >oin inde8 direct"y/ you create a
view that "oo&s "i&e the >oin inde8 and in that way/ it wou"d e simi"ar to
havin# direct access. However/ this approach does not #uarantee that the
>oin inde8 wi"" e used.
%=at is diFerence BKw ser and data<ase in Teradata9
Answer:
6 Iser is a dataase with password ut dataase cannot have password
6 Both can contain Ta"es / views and macros
6 Both users and dataases may or may not ho"d privi"e#es
6 'n"y users can "o#in/ esta"ish a session with Teradata dataase and they
can sumit re+uests
EC,.ain "iFerent t@,es o> te+,orar@ ta<.es in Teradata
"erived te+,orar@ ta<.es
Z Aerived ta"es are "oca" to an SQ* +uery.
Z Not inc"uded in the AB( data dictionary dataase/ the de1nition is &ept in
cache.
Z They are speci1ed on a +uery "eve" with an AS &eyword in an s+"
statement
Lo.ati.e te+,orar@ ta<.es
Z *oca" to a session , de"eted automatica""y when the session terminates-
Z Not inc"uded in the AB( data dictionary dataase and ta"e de1nition is
stored in cache. However/ the vo"ati"e ta"es need to have uni+ue names
across the session.
Z (reated y the ()EATE W'*ATI*E TAB*E s+" statement
'.o<a. te+,orar@ ta<.es
Z F"oa" ta"es are "oca" to a session and de"eted automatica""y when the
session terminates
Z A permanent ta"e de1nition is stored in the AB( data dictionary
dataase ,AB(.Tempta"es-
Z de1ned with the ()EATE F*'BA* TEJ@')A)C TAB*E s+"
&ow do @ou -nd out nu+<er o> AMPMs in t=e 'iven s@ste+9
Answer: Se.ect HASHAJ@ ,- N.5
List t@,es o> &AS& >unctions used in teradata9
There are HASH)'%/ HASHBI(7ET/ HASHAJ@ and HASHBA7AJ@.
The SQ* hash !unctions areK
HASH)'% ,co"umn,s--
HASHBI(7ET ,hashrow-
HASHAJ@ ,hashuc&et-
HASHBA7AJ@ ,hashuc&et-
E8amp"eK
SELECT
HASH)'% ,;Teradata;- AS ?Hash Wa"ue?
/ HASHBI(7ET ,HASH)'% ,;Teradata;-- AS ?Buc&et Num?
/ HASHAJ@ ,HASHBI(7ET ,HASH)'% ,;Teradata;--- AS ?AJ@ Num?
/ HASHBA7AJ@ ,HASHBI(7ET ,HASH)'% ,;Teradata;--- AS ?AJ@
9a""ac& Num? 5
%=at are t=e <asic criteria to se.ect Pri+ar@ IndeC co.u+n >or a
;iven ta<.e9
Answer:
A thum ru"e o! A"L demo#raphics is !o""owed.
Access "e+o;ra,=ics
Identi!y inde8 candidates that ma8imiUe one6AJ@ operations.
(o"umns most !re+uent"y used !or access ,Wa"ue and =oin-.
"istri<ution "e+o;ra,=ics
Identi!y inde8 candidates that optimiUe para""e" processin#.
(o"umns that provide #ood distriution.
Lo.ati.it@ "e+o;ra,=ics
Identi!y inde8 candidates with "ow maintenance I/'.
%=at are t=e <asic ru.es t=at de-ne =ow PI is de-ned in Teradata9
Answer:
The !o""owin# ru"es #overn how @rimary Inde8es in a Teradata Aataase must
e de1ned as we"" as how they !unctionK
'ne @rimary Inde8 per ta"e.
A @rimary Inde8 va"ue can e uni+ue or non6uni+ue.
The @rimary Inde8 va"ue can e NI**.
The @rimary Inde8 va"ue can e modi1ed.
The @rimary Inde8 o! a popu"ated ta"e cannot e modi1ed.
A @rimary Inde8 has a "imit o! OP co"umns.
&ow to +a3e sure O,ti+iJer c=ooses NSI over )u.. Ta<.e Scan
G)TSI9
Answer:
A optimiUer wou"d pre!er 9TS over NISI/ when there are no Statistics de1ned
on NISI co"umns.
It is a"ways su##ested to co""ect statistics whenever NISI co"umns are
de1ned on the ta"e.
Weri!y whether inde8 is ein# used y chec&in# in E8p"ain p"an.
%=at are t=e advanta;es and dis-advanta;es o> secondar@ IndeCes9
Answer:
Advanta;es:
.. A secondary inde8 mi#ht e created and dropped dynamica""y
0.A ta"e may have up to M0 secondary inde8es.
M. Secondary inde8 can e created on any co"umn. .Either Ini+ue or Non6
Ini+ue
P. It is used as a"ternate path or *east !re+uent"y used cases. e8. de1nin# SI
on non inde8ed co"umn can improve the per!ormance/ i! it is used in >oin or
1"ter condition o! a #iven +uery.
Q. (o""ectin# Statistics on SI co"umns ma&e sure 'ptimiUer
"isadvanta;es
.. Since Su ta"es are to e created/ there is a"ways an overhead !or
additiona" spaces.
0. They re+uire additiona" I/'s to maintain their su ta"es.
M. The 'ptimiUer may/ or may not/ use a NISI/ dependin# on its se"ectivity.
P. I! the ase ta"e is 9a""ac&/ the secondary inde8 su ta"e is 9a""ac& as
we"".
Q. I! statistics are not co""ected accordin#"y/ then the optimiUer wou"d #o !or
9u"" Ta"e Scan.
%=en s=ou.d t=e statistics <e co..ected9
Answer:
Here are some e8ce""ent #uide"ines on when to co""ect statisticsK
[ A"" Non6Ini+ue indices
[ Non6inde8 >oin co"umns
[ The @rimary Inde8 o! sma"" ta"es
[ @rimary Inde8 o! a =oin Inde8
[ Secondary Indices de1ned on any >oin inde8
[ =oin inde8 co"umns that !re+uent"y appear on any additiona" >oin inde8
co"umns that !re+uent"y appear in %HE)E search conditions
[ (o"umns that !re+uent"y appear in %HE)E search conditions or in the
%HE)E c"ause o! >oins.
%=ere does T" store transient Dourna.9
Answer:
In perm space 6G dc.transient>ourna"
But that specia" ta"e can #row over dc;s perm "imit unti" the who"e system
runs out o! perm space.
&ow can @ou -nd t=e Teradata Re.ease and Lersion >ro+ "ata
"ictionar@ Ta<.e9
Answer:
SELECT * )ROM AB(.AB(IN9'5

&ow can @ou deter+ine IKO and CP usa;e at a user .eve. in
Teradata9
Answer:
SELECT A(('INTNAJE/ ISE)NAJE/ SIJ ,CPTIME- AS (@I/ SIJ
,AIS7I'- AS AIS7I'
)ROM AB(.AJ@ISAFE
'ROP B! ./0
OR"ER B! M "ESC5
&ow can @ou trac3 Lo;in Para+eters o> users in Teradata9
Answer:
SELECT *'FAATE/ *'FTIJE/ ISE)NAJE/ EWENT )ROM AB(.*'F'N'995
(an you recover the password o! a user in Teradata?
Answers:
No/ you canSt recover the password o! a user in Teradata. @asswords are
stored in this data
Aictionary ta"e ,AB(.ABASE- usin# a one6way encryption method. Cou can
view the
Encrypted passwords usin# the !o""owin# +uery
SE*E(T * 9)'J AB(.ABASE5
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$
EC,.ain )erret ti.it@ in Teradata9
9erret ,9i"e )econ1#uration too"- is an uti"ity which is used to disp"ay and set
Ais& Space
Iti"iUation parameters within Teradata )ABJS. %hen you se"ect the 9erret
Iti"ity
parameters/ it dynamica""y recon1#ures the data on dis&s. %e can run this
uti"ity throu#h
Teradata Jana#er5 to start the 9erret Iti"ity type ,STA)T 9E))ET- in the
dataase window.
AnswersK
9o""owin# commands can e used within 9erret Iti"ityK
.. SH'%S@A(E R %e"" this command reports you the amount o! Ais& (y"inder
Space is in use and the amount o! Ais& (y"inder Space is avai"a"e in the
system. This wi"" #ive you an in!ormation aout @ermanent Space cy"inders/
Spoo" Space cy"inders/ Temporary Space cy"inders/ =ourna"in# cy"inders/ Bad
cy"inders and 9ree cy"inders. 9or each o! these Q thin#s it wi"" present you M
parameters i.e. Avera#e Iti"iUation per cy"inder/ < o! tota" ava"ia"e cy"inders
and numer o! cy"inders.
0. SH'%B*'(7S R This command wi"" he"p you in identi!yin# the Aata B"oc&
siUe and the numer o! )ows per data "oc&. This command disp"ays the Ais&
Space in!ormation !or a de1ned ran#e o! Aata B"oc&s and (y"inders.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
EC,.ain TPMP GTeradata Para..e. "ata Pu+,I ti.it@ in Teradata9
Answers:
* T@IJ@ a""ows near rea" time updates !rom Transactiona" Systems into the
Aata %arehouse.
* It can per!orm Insert/ Ipdate and Ae"ete operations or a comination !rom
the same source.
* It can e used as an a"ternative to J*'AA !or "ow vo"ume atch
maintenance o! "ar#e dataases.
* T@IJ@ a""ows tar#et ta"es to have Secondary Inde8es/ =oin Inde8es/ Hash
Inde8es/ )e!erentia" Inte#rity/ @opu"ated or Empty Ta"e/ Ju"tiset or Set Ta"e
or Tri##ers de1ned on the Ta"es.
* T@IJ@ can have many sessions as it doesnSt have session "imit.
* T@IJ@ uses row hash "oc&s thus a""owin# concurrent updates on the same
ta"e.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow can @ou -nd t=e Ta<.e S,ace SiJe o> @our ta<.e across a.. AMPs9
Answers:
Cou can 1nd the Ta"e Space SiUe o! your ta"e !rom this Aata Aictionary
Ta"e AB(.TAB*ESIYE
SE*E(T AATABASENAJE/ TAB*ENAJE/ SIJ,(I))ENT@E)J- 9)'J
AB(.TAB*ESIYE %HE)E AATABASENAJE $ TS ANA TAB*ENAJE $ TS F)'I@ BC
AATABASENAJE / TAB*ENAJE5
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow can @ou use &AS& )NCTIONS to view "ata "istri<ution across
a.. AMPs in Teradata9
Answers:
Hash 9unctions can e used to view the data distriution o! rows !or a chosen
primary inde8.
SE*E(T HASHAJ@,HASHBI(7ET,HASH)'%,@I co"umn--- AS AJ@no/
('INT,*- 9)'J 2ta"e nameG F)'I@ BC . ')AE) BC 0 AES(5
HASH)'% R returns the row hash va"ue !or a #iven va"ue
HASHBI(7ET R the #roupin# o! a speci1c hash va"ue
HASHAJ@ R the AJ@ that is associated with the hash uc&et
This is rea""y #ood/ y "oo&in# into the resu"t set o! aove written +uery you
can easi"y 1nd out the Aata Aistriution across a"" AJ@s in your system and
!urther you can easi"y identi!y un6even data distriution.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow do @ou trans>er .ar;e a+ount o> data in Teradata9
Answers:
Trans!errin# o! "ar#e amount o! data can e done usin# various App"ication
Teradata Iti"ities which resides on the host computer , Jain!rame or
%or&station- i.e. BTEQ/ 9ast*aod/ Ju"ti*oad/ Tpump and 9astE8port.
* BTEQ ,Basic Teradata Query- supports a"" P AJ*sK SE*E(T/ INSE)T/ I@AATE
and AE*ETE. BTEQ a"so support IJ@')T/EL@')T protoco"s.
* 9ast"oad/ Ju"ti*oad and Tpump trans!er the data !rom Host to Teradata.
* 9astE8port is used to e8port data !rom Teradata to the Host.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow does &as=in; =a,,ens in Teradata9
Answers:
* Hashin# is the mechanism throu#h which data is distriuted and retrieved
to/!rom AJ@s.
* @rimary Inde8 ,@I- va"ue o! a row is the input to the Hashin# A"#orithm.
* )ow Hash ,M06it numer- va"ue is the output !rom this A"#orithm.
* Ta"e Id N )ow Hash is used to "ocate (y"inder and Aata "oc&.
* Same @rimary Inde8 va"ue and data type wi"" a"ways produce same hash
va"ue.
* )ows with the same hash va"ue wi"" #o to the same AJ@.
So data distriution depends direct"y on the )ow Hash uni+ueness5 e care!u"
whi"e (hoosin# Inde8es in Teradata.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow to e.i+inate Product *oins in a Teradata SBL quer@9
Answers:
.. Ensure statistics are co""ected on >oin co"umns and this is especia""y
important i! the co"umns you are >oinin# on are not uni+ue.
0. Ja&e sure you are re!erencin# the correct a"ias.
M. A"so/ i! you have an a"ias/ you must a"ways re!erence it instead o! a !u""y
+ua"i1ed ta"ename.
P. Sometimes product >oins happen !or a #ood reason. =oinin# a sma"" ta"e
,.44 rows- to a "ar#e ta"e ,. mi""ion rows- a product >oin does ma&e sense.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow to se.ect -rst N Records in Teradata9
Answers:
To se"ect N records in Teradata you can use )AN7 !unction. Query synta8
wou"d e as !o""ows
SE*E(T B''7:NAJE/ B''7:('INT/ )AN7,B''7:('INT- A 9)'J *IB)A)C
QIA*I9C A 2$ .45
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
&ow to view ever@ co.u+n and t=e co.u+ns contained in indeCes in
Teradata9
Answers:
9o""owin# +uery descries each co"umn in the Teradata )ABJS
SE*E(T * 9)'J AB(.TW9ie"ds5
9o""owin# +uery descries co"umns contained in inde8es in the Teradata
)ABJS
SE*E(T * 9)'J AB(.Inde8es5
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at are t=e 6 ,=ases in a Mu.tiLoad ti.it@9
Answers:
* @re"iminary @hase R Basic Setup
* AJ* @hase R Fet AJ* steps down on AJ@s
* Ac+uisition @hase R Send the input data to the AJ@s and sort it
* App"ication @hase R App"y the input data to the appropriate Tar#et Ta"es
* End @hase R Basic ("eanup
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at are t=e >unctions o> a Teradata "BA9
Answers:
9o""owin# are the diBerent !unctions which a ABA can per!ormK
.. Iser Jana#ement R (reation and mana#in# Isers/ Aataases/ )o"es/
@ro1"es and Accounts.
0. Space A""ocation R Assi#nin# @ermanent Space/ Spoo" Space and
Temporary Space.
M. Access o! Aataase '>ects R Frantin# and )evo&in# Access )i#hts on
diBerent dataase o>ects.
P. Security (ontro" R Hand"in# "o#on and "o#oB ru"es !or Isers.
Q. System Jaintenance R Speci1cation o! system de!au"ts/ restart etc.
O. System @er!ormance R Ise o! @er!ormance Jonitor,@J'N-/ @riority
Schedu"er and =o Schedu"in#.
3. )esource Jonitorin# R Aataase Query *o#,ABQ*- and Access *o##in#.
\. Aata Archives/ )estores and )ecovery R A)( Iti"ity and @ermanent
=ourna"s.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at are t=e Mu.tiLoad ti.it@ .i+itations9
Answers:
Ju"ti*oad is a very power!u" uti"ity5 it has !o""owin# "imitationsK
* Ju"ti*oad Iti"ity doesnSt support SE*E(T statement.
* (oncatenation o! mu"tip"e input data 1"es is not a""owed.
* Ju"ti*oad doesnSt support Arithmatic 9unctions i.e. ABS/ *'F etc. in J"oad
Script.
* Ju"ti*oad doesnSt support E8ponentiation and A##re#ator 'perators i.e.
AWF/ SIJ etc. in J"oad Script.
* Ju"ti*oad doesnSt support ISIs ,Ini+ue Secondary Inde8es-/ )e!rentia"
Inte#rity/ =oin Inde8es/ Hash Inde8es and Tri##ers.
* Import tas& re+uire use o! @I ,@rimary Inde8-.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at are TPMP ti.it@ Li+itations9
Answers:
9o""owin# are the "imitations o! Teradata T@IJ@ Iti"ityK
* Ise o! SE*E(T statement is not a""owed.
* (oncatenation o! Aata 9i"es is not supported.
* E8ponentia" V A##re#ate 'perators are not a""owed.
* Arithmatic !unctions are not supported.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at is )ILLER co++and in Teradata9
Answers:
%hi"e runnin# 9ast"oad or Ju"ti"oad i! you donSt want to "oad a particu"ar 1e"d
!rom the data1"e to the tar#et ta"e then use the 9I**E) command to achieve
this. Synta8 !or 9I**E) command wou"d e as !o""owin#K
.*AC'IT 9I*E:@)'AI(T5 /* It is input 1"e "ayout name */
.9IE*A @rod:No * char,..-5 /* To "oad data into @rod:No */
.9IE*A @rod:Name * char,..-5 /* To "oad data into @rod:Name */
.9IE*A *ocation * char,..-5 /* To "oad data into *ocation */
.9I**E) @rod:(hars * char,04-5 /* To s&ip the va"ue !or the ne8t Q "ocations */
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at is t=e diFerence <etween Access Lo;;in; and Buer@ Lo;;in;
in Teradata9
Answers:
.. Access *o##in# is concerned with security ,i.e. whoSs is doin# what-. In
access "o##in# you as& the dataase to "o# whoSs doin# what on a #iven
o>ect. The in!ormation stored is ased on the o>ect not the SQ* 1red or the
user who 1red it.
0. Query *o##in# ,ABQ*- is used !or deu##in# ,i.e. whatSs happenin# around
?-. Incase o! ABQ* dataase &eep on trac&in# various parameters i.e. the
SQ*s/ )esource/ Spoo" Isa#e/ Steps and other thin#s which he"p you
understand whatSs #oin# on/ the in!ormation is !ruit!u" to deu# a pro"em.
9urther ABQ* is ena"ed on a Iser id rather than an o>ect "i&e say Ta"e or
so.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at is t=e diFerence <etween Su<-Buer@ N Co-Re.ated Su<-Buer@9
Answers:
%hen +ueries are written in a nested manner then it is termed as a su6
+uery. A Su6Query #et e8ecuted once !or the parent statement whereas (o6
)e"ated Su6Query #et e8ecuted once !or each row o! the parent +uery.
Se"ect Empname/ Aeptno/ Sa"ary !rom Emp"oyee Emp where Sa"ary $ ,Se"ect
Ja8,Sa"ary- !rom Emp"oyee where Aeptno $ Emp.Aeptno- order y Aeptno
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$
%=at is Recon-;uration ti.it@ in Teradata and %=at it is used >or9
Answers:
* %hen we !eed @rimary Inde8 va"ue to Hashin# A"#orithm then it #ives us
)ow Hash,M0 it numer- va"ue which is used to ma&e entries into Hash
Japs.
* Hash Japs are the mechansim !or determinin# which AJ@ wi"" e #ettin#
that row.
* Each Hash Jap is an array o! OQ/QMO entries and its siUe is c"ose to .0\7B.
%hen Teradata is insta""ed on a system then there are some scrpits which we
need to e8ecute i.e. AI@ Scripts. So it creates a Hash Japs o! OQ/QMO entries
!or the current con1#uration. But what i! you want to add some more AJ@s
into your system?
)econ1#uration ,)econ1#- is a techni+ue !or chan#in# the con1#uration ,i.e.
chan#in# the numer o! AJ@s in a system- and is contro""ed y the
)econ1#uration Hash Japs. System ui"ds )econ1#uration Hash Japs y
reassi#nin# hash map entries to re]ect new con1#uration o! system.
*ets understand this concept with the he"p o! an e8amp"e5 suppose you have
a P AJ@s system which ho"ds OQ/QMO entries. Each AJ@ is responsi"e !or
ho"din# ,OQ/QMO/P$.O/M\P- .O/M\P entries.
Now you have added 0 more AJ@s in your current con1#uration so you need
to recon1#ure your system. Now each AJ@ wou"d e responsi"e !or ho"din#
,OQ/QMO/O$.4X00- .4/X00 entries.
Teradata Doins
%hen we >oin two or more ta"es on a co"umn or set o! co"umns/ =oinin# ta&es
p"ace. This wi"" resu"t in data resu"tin# !rom matchin# records in oth the
ta"es. This Iniversa" concept remains the same !or a"" the dataases.
In Teradata/ we have 'ptimiUer ,a very smart Interpreter-/ which determines
type o! >oin strate#y to e used ased on user input ta&in# per!ormance
!actor in mind.
In Teradata/ some o! common >oin types are used "i&e
6 Inner >oin ,can a"so e ?se"! >oin? in some cases-
6 'uter =oin ,*e!t/ )i#ht/ 9u""-
6 (ross >oin ,(artesian product >oin-
%hen Iser provides >oin +uery/ optimiUer wi"" come up with >oin p"ans to
per!orm >oins. These =oin strate#ies inc"ude
6 Jer#e =oin
6 Nested =oin
6 Hash =oin
6 @roduct >oin
6 E8c"usion =oin
Mer;e *oin
--------------------
Jer#e >oin is a concept in which rows to e >oined must e present in same
AJ@. I! the rows to e >oined are not on the same AJ@/ Teradata wi"" either
redistriute the data or dup"icate the data in spoo" to ma&e that happen
ased on row hash o! the co"umns invo"ved in the >oins %HE)E ("ause.
I! two ta"es to e >oined have same primary Inde8/ then the records
wi"" e present in Same AJ@ and )e6Aistriution o! records is not re+uired.
There are !our scenarios in which redistriution can happen !or Jer#e =oin
Case 4: I! >oinin# co"umns are on PI $ PI/ the records to e >oined are
present in Same AJ@ and redistriution is not re+uired. This is most eHcient
and !astest >oin strate#y
Case 8: I! >oinin# co"umns are on PI $ Non IndeC co.u+n/ the records in
0nd ta"e has to e redistriuted on AJ@;s ased on data correspondin# to
1rst ta"e.
Case O: I! >oinin# co"umns are on Non IndeC co.u+n $ Non IndeC co.u+n
/ the oth the ta"es are to e redistriuted so that matchin# data "ies on
same amp / so the >oin can happen on redistriuted data. This strate#y is
time consumin# since comp"ete redistriution o! oth the ta"es ta&es across
a"" the amps
Case :: 9or >oin happenin# on @rimary Inde8/ I! the )e!erenced ta"e ,second
ta"e in the >oin- is very sma""/ then this ta"e is dup"icated /copied on to
every AJ@.
Nested *oin
-------------------
Nested =oin is one o! the most precise >oin p"ans su##ested y 'ptimiUer
.Nested =oin wor&s on I@I/ISI used in =oin statement and is used to retrieve
the sin#"e row !rom 1rst ta"e . It then chec&s !or one more matchin# rows in
second ta"e ased on ein# used in the >oin usin# an inde8 ,primary or
secondary- and returns the matchin# resu"ts.
Example:
Se.ect EJ@.Ename / AE@.Aeptno/ EJ@.sa"ary
>ro+
EJ@*'CEE EJ@ /
AE@A)TJENT AE@
%=ere EJ@.Enum $ AE@.Enum
and EJp.Enum$ 0MPQ5 -- this results in nested join
&as= Doin
----------------
Hash >oin is one o! the p"ans su##ested y 'ptimiUer ased on >oinin#
conditions. %e can say Hash =oin to e c"ose re"ative o! Jer#e ased on its
!unctiona"ity. In case o! mer#e >oin/ >oinin# wou"d happen in same amp. In
Hash =oin/ one or oth ta"es which are on same amp are 1t comp"ete"y
inside the AJ@;s Jemory . Amp chooses to ho"d sma"" ta"es in its memory
!or >oins happenin# on )'% hash.
Advanta#es o! Hash >oins are
.. They are !aster than Jer#e >oins since the "ar#e ta"e doesnSt need to e
sorted.
0. Since the >oin happenin# /w ta"e in AJ@ memory and ta"e in unsorted
spoo"/ it happens so +uic&"y.
ECc.usion *oin
-------------------------
These type o! >oins are su##ested y optimiUer when !o""owin# are used in
the +ueries
6 N'T IN
6 EL(E@T
6 JINIS
6 SET sutraction operations
Se.ect EJ@.Ename / AE@.Aeptno/ EJ@.sa"ary
>ro+
EJ@*'CEE EJ@
%&ERE EJ@.Enum NOT IN
, Se.ect Enum >ro+
AE@A)TJENT AE@
w=ere Enum is NOT NLL -5
@"ease ma&e sure to add an additiona" %HE)E 1"ter Dwit= 0co.u+n1 IS
NOT NLLE since usa#e o! NI** in a N'T IN 2co"umnG "ist wi"" return no
resu"ts.
E8c"usion >oin !or !o""owin# N'T In +uery has M scenarios
Case 4: matched data in ?N'T IN? su Query wi"" dis+ua"i!y that row
Case 8: Non6matched data in ?N'T IN? su Query wi"" +ua"i!y that row
Case O: Any In&nown resu"t in ?N'T IN? wi"" dis+ua"i!y that row 6 ,;NI**; is a
typica" e8amp"e o! this scenario-.
"iFerence <etween read .oc3 and access .oc39
9or access "oc& to e p"aced we have to speci!y it e8p"icit"y as *'(7INF 9')
A((ESS.
Access "oc& is one wherein the ta"e is not "oc&ed means you can do
insert/update/de"ete on
the ta"e whi"e access "oc& wi"" access the ta"e /in this the dirty reads may
happen / which
means you wi"" not #et the "atest chan#es whatever happened on ta"e to e
re]ected in your
answer set.
)EAA "oc& wi"" "oc& the ta"e wherein you can not do insert/update and
structura" chan#es in
ta"e.
It is p"aced y simp"e SE*E(T statement !or y e8p"icit"y speci!yin# as
*'(7INF 9') )EAA.
S@ntaC:
read .oc3 :
*oc&in# ta"e !or Access5
access .oc3 :
*oc&in# ta"e !or )ead Access
The main diBerence etween read "oc& and access "oc& is data Inte#rity.'n
p"acin# a read "oc& the user e8pects data inte#rity/ whi"e as !or access "oc&
the user cannot e8pect data inte#rity.
(onsider !o""owin# scenarios
.. Iser A p"aces )EAA "oc& and Iser B %)ITE p"aces "oc&
Iser B wi"" have to wait !or Iser A to comp"ete its read in order to start
insert/updates/de"etes on the data.
0. Iser A p"aces A((ESS "oc& and Iser B %)ITE p"aces "oc&.
Iser A V B access the data simu"taneous"y/ hence Iser A cannot e8pect to
#et consistent resu"ts.
&ow to create and use Macro 9
A macro is a Teradata e8tension to ANSI SQ* that contains pre written SQ*
statements. Jacros are used to run a repeata"e set o! tas&s. The detai"s o!
macro can e !ound in data dictionary ,AA- . Jacros are dataase o>ects
and thus they e"on# to a speci1ed user or dataase. A macro can e
e8ecuted y Queryman. / BTEQ/ y another macro.
&ow to create a Macro
(reate a macro to #enerate a A'B "ist !or department M0.K
()EATE JA()' A'B:Aetai"s AS
,SE*E(T 1rst:name /"ast:name /A'B
9)'J TE)AAATA.emp"oyees
%HE)E dept:numr $M0.
')AE) BC A'B asc5-5
E#ECTE a Macro
To e8ecute a macro/ ca"" it a"on# with the e8ec command.
ELE( A'B:Aetai"s5
"ast:name 1rst:name A'B
)am 7umar 3Q/40/00
*a8man Sinha 3X/4P/4O
"ROP a Macro
To drop a macro/ use !o""owin# command .
A)'@ JA()' A'B:Aetai"s5
REPLACE a Macro
I! we need to modi!y an e8istin# macro / instead o! droppin# and re6creatin#
it
%e can use rep"ace macro command as !o""ows
)E@*A(E JA()' A'B:Aetai"s AS
,SE*E(T 1rst:name/"ast:name /A'B
9)'J TE)AAATA.emp"oyees
%HE)E dept:numr $ M0.
')AE) BC A'B/ 1rst:name5-5
Para+eteriJed Macros
@arametriUed macros a""ow usa#e o! varia"es . we can pass va"ues to these
varia"es. Advanta#e o! usin# parametriUed macros is / Wa"ues can e
passed to these varia"es at run6time.
E8amp"e
()EATE JA()' dept:"ist ,dept INTEFE)- AS
,
SE*E(T "ast:name
9)'J TE)AAATA.emp"oyees
%HE)E dept:numr $ Kdept5 -5
To E8ecute the macro
ELE( dept:"ist ,M0.-5
Jacros may have more than one parameter. Each name and its associated
type are separated y a comma !rom the ne8t name and its associated type.
The order is important. The 1rst va"ue in the ELE( o! the macro wi"" e
associated with the 1rst va"ue in the parameter "ist. The second va"ue in the
ELE( is associated with the second va"ue in the parameter "ist/ and so on.
E8amp"e
()EATE JA()' emp:veri!y ,dept:numr INTEFE) /sa"ary AE(,.\/4--
AS ,
SE*E(T emp:numr
!rom TE)AAATA.emp"oyees
%HE)E dept:numr $ :de,t
ANA sa"ary2 :sa.5- 5
To E8ecute this macro
ELE( emp:chec& ,M4./ Q4444-5
7ey points to note aout JacrosK
Jacros are a Teradata e8tension to SQ*.
Jacros can on"y e e8ecuted with the ELE( privi"e#e.
Jacros can provide co"umn "eve" security.
NOTE: A user must have ELE( privi"e#es to e8ecute the macros. It doesn;t
matter i!
he has privi"e#es !or the under"yin# ta"es or views that the macro uses.
Pe>or+ance tunin; Ti,s : *oin Considerations
I! you are wor&in# on writin# +ueries/ wor&in# on per!ormance or he"pin# in
etterment o! per!ormance. Cou wi"" have to ta&e sometime in #oin# throu#h
this topic. It is a"" to do aout =oins which is most important concern in
Teradata.
I! some "i#ht is #iven to !o""owin# su##estions/ any >oin re"ated issues can e
ta&en care oB...
Ti, 4: *oinin; on PIKNPIK Non PI co.u+ns
%e shou"d ma&e sure >oin is happenin# on co"umns composed o! I@I/NI@I.
But why??
%henever we >oin two ta"es on common co"umns/ the smart optimiUer wi""
try to ta&e data !rom oth the data into a common spoo" space and >oin them
to #et resu"ts. But #ettin# data !rom oth the ta"es into common spoo" has
overhead.
%hat i! I >oined a very "ar#e ta"e with sma"" ta"e?
Shou"d sma"" ta"e e redistriuted or "ar#e ta"e?
Shou"d sma"" ta"e e dup"icated across a"" the AJ@s?
Shou"d oth the ta"es e redistriuted across a"" the AJ@s??
Here is some asic thum ru"es on >oinin# co"umns on Inde8/ so >oinin#
happens !aster.
Case 1 - P.I = P.I joins
There is no redistriution o! data over amp;s. Since amp "oca" >oins happen
as data are present in same AJ@ and need not e re6distriuted. These types
o! >oins on uni+ue primary inde8 are very !ast.
Case 2 - P.I = Non PI column joins
6Aata !rom second ta"e wi"" e re6distriuted on a"" amps since >oins are
happenin# on @I vs. NI@I co"umn. Idea" scenario is when sma"" ta"e is
redistriuted to e >oined with "ar#e ta"e records on same amp
6Aata in sma"" ta"e is dup"icated to Every AJ@ where it is >oined "oca""y with
"ar#e ta"e
Case 3 - No Index = Non PI column joins
Aata !rom oth the ta"es are redistriuted on a"" AJ@s. This is one o! the
"on#est processin# +ueries / (are shou"d e ta&en to see that stats are
co""ected on these co"umns
Ti, 8: T=e co.u+ns ,art o> Doin +ust <e o> t=e sa+e data t@,e
GC&AR2 INTE'ER2I( But w=@9P9
%hen tryin# to >oin co"umns !rom two ta"es/ optimiUer ma&es sure that
datatype is same or e"se it wi"" trans"ate the co"umn in drivin# ta"e to match
that o! derived ta"e.
Say !or e8amp"e
TAB*E emp"oyee deptno ,char-
TAB*E dept deptno ,inte#er-
I! I am >oinin# emp"oyee ta"e with Aept on emp"oyee.deptno,char- $
dept.deptno,Inte#er-/ optimiUer wi"" convert character co"umn to Inte#er
resu"tin# in trans"ation . %hat wou"d happen i! emp"oyee ta"e had .44
mi""ion records and every time deptno wou"d have to under#o Trans.ation.
So we have to ma&e sure to avoid such scenarios since trans"ation is a cost
!actor and mi#ht need time and system resources.
Ja&e sure you are >oinin# co"umns that have same data types to avoid
trans"ation^^^^
Ti, O : "o not use >unctions .i3e SBSTR2 COALESCE 2 CASE ((( on t=e
indices used as ,art o> *oin( %=@9P9
It is not recommended not to use !unctions such as SIBST)/ ('A*ES(E/
(ASE and others since they add up to cost !actor resu"tin# in per!ormance
issue.
'ptimiUer wi"" not e a"e to read stats on those co"umns which have
!unctions as it is usy convertin# !unctions. This mi#ht resu"t in @roduct >oin/
spoo" out issues and optimiUer wi"" not e a"e to ta&e decisions since no
stats/demo#raphics are avai"a"e on co"umn. It mi#ht assume co"umn to
have .44 va"ues instead o! . mi""ion va"ues and mi#ht redistriute on wron#
assumption direct"y impactin# per!ormance.
Ti, : : use NOT NLL w=ere ever ,ossi<.eP
%hat?^^ Aid someone say Not Nu""?? .. Ces/ we have to ma&e sure to use
N'T nu"" !or co"umns which are dec"ared as NI**AB*E in TAB*E de1nition.
)eason ein# that a"" the Nu"" va"ues mi#ht #et sorted to one poor AJ@
resu"tin# in in!amous ? N' S@''* S@A(E ? Error as that AJ@ cannot
accommodate any more Nu"" va"ues.
S' rememer to use N'T NI** in >oinin# so that ta"e S7E% can e avoid .
Since W0)Q / teradata automatica""y adds the condition _ IS N'T NI** ` to
the +uery. Sti"" it is etter to ensure N'T NI** co"umns are not inc"uded as
part o! the >oin
*oc&in# ta"e !or access?
%e wou"d have come across this statement in many +ueries which are run in
sensitive environments "i&e @)'A/ IAT. They can e used with views or
sometimes >ust !or +ueryin# purpose.
I wanted to discuss how important this statement wou"d e in rea"6time
/active data warehouses where "ot o! users wi"" e stri&in# +ueries on same
dataase at the time.
create view Emp"oyee.view:emp"oy:with*oc&
as
.oc3in; ta<.e Emp"oyee.Aept:emp >or access
se.ect *
>ro+ Emp"oyee.Aept:emp 5
By usin# "oc&in# ta"e !or access/ we ma&e sure that norma" ?access? "oc& is
app"ied on ta"e which is re+uired to !etch resu"ts. By doin# so /
6 There is no waitin# !or other "oc&s to re"ease since access "oc& can e
app"ied on ta"e which has read/write "oc& app"ied to it
6 This wi"" cause the +uery to e8ecute even when some "oc& is app"ied / ut
accessin# data usin# this "oc& mi#ht not e consistent as it mi#ht resu"t in
dirty read due to concurrent write on the same ta"e.
It is a"ways su##ested to use D"oc&in# ta"e !or access? which since they wi""
not "oc& the other users !rom app"yin# read/write "oc& on the ta"e.
%hi"e tunin# +ueries in Teradata / %e ta&e care o! ma>or per!ormance issues
ut i#nore sma"" cases which mi#ht sti"" cause the +uery to per!orm ad"y.
I wanted to mention aout one such case o! LI$E c.ause / which many
peop"e #ood at per!ormance tunin# miss it assumin# "i&e patterns does not
harm the per!ormance . But in rea"ity this is not so^^
I! *I7E is used in a %HE)E c"ause/ it is etter to try to use one or more
"eadin# character in the c"ause/ i! at a"" possi"e.
e#5 *I7E ;<STRIN'<; wi"" e processed diBerent"y compared to *I7E
;STRIN'<;
I! a "eadin# character MSTRIN'QM is used in the e#inin# o! "i&e c"ause /
the the QptimiUer ma&es use o! an inde8 to per!orm on +uery therey
increasi# the per!ormance
But i! the "eadin# character; in MQSTRIN'QM is a wi"dcard,say ;<;- / then the
'ptimiUer wi"" not e a"e to use an inde8/ and a !u"" ta"e scan ,9TS - must
e run/ which reduces per!ormance and ta&es more time.
Hence it is su##ested to #o !or MQSTRIN'QM on"y i! STRIN' is a part o!
entire pattern say ;SIBSTRIN';
Per>or+ance tunin; t=u+< ru.es(
Here are very asic steps which are used to @T any #iven +uery in #iven
environment . As a pre6re+uiste / ma&e sure
6 user has proper se"ect ri#hts and actua" pro1"e settin#s
6 Enou#h space avai"a"e to run and test the +ueries
.. )un e8p"ain p"an ,pressin# 9O or DEL@*AIN se" * aE/-
Then see !or potentia" in!ormation "i&e
6 No or "ow con1dence
6 @roduct >oins conditions
6 By way o! an a"" row scan 6 9TS
6 Trans"ate
A"so chec& !or
6 "istinct or ;rou, y &eywords in SQ* +uery
6 In/ not in &eywords and chec& !or the "ist o! va"ues #enerated !or the same
APPROAC&ES
A. In case o! ,roduct Doin scenarios/chec& !or
6 @roper usa#e o! a"ias
6 >oinin# on matchin# co"umns
6 Isa#e o! >oin &eywords 6 "i&e speci!yin# type o! >oins ,e8. inner or outer -
6 use union in case o! RORS scenarios
6 Ensure statistics are co""ected on >oin co"umns and this is especia""y
important i! the co"umns you are >oinin# on are not uni+ue.
B. co..ects stats
6 )un command ?dia#nostic he"p stats on !or the session?
6 Father in!ormation on co"umns on which stats has to e co""ected
6 (o""ect stats on su##estions co"umns
6 A"so chec& !or stats missin# on @I/ SI or co"umns used in >oins 6 ?he"p stats
2dataasenameG.2ta"enameG
6 Ja&e sure stats are re6co""ected when at6"east .4< o! data chan#es
6 remove unwanted stats or stat which hard"y improves per!ormance o! the
+ueries
6 (o""ect stats on co"umns instead o! inde8es since inde8 dropped wi"" drop
stats as we""^^
6 co""ect stats on inde8 havin# mu"tip"e co"umns/ this mi#ht e he"p!u" when
these co"umns are used in >oin conditions
6 (hec& i! stats are re6created !or ta"es whose structures have some
chan#es
c. )u.. ta<.e scan scenarios
6 Try to avoid 9TS scenarios as/ it mi#ht ta&e very "on# time to access a"" the
data in every amp in the system
6 Ja&e sure SI is de1ned on the co"umns which are used as part o! >oins or
A"ternate access path.
6 (o""ect stats on SI co"umns e"se there are chances where optimiUer mi#ht
#o !or 9TS even when SI is de1ned on that particu"ar co"umn
0. I! inter+ediate ta<.es are used to store resu"ts/ ma&e sure that
6 It has same @I o! source and destination ta"e
M. Tune to #et the optimiUer to >oin on the @rimary Inde8 o! the "ar#est ta"e/
when possi"e/ to ensure that the .ar;e ta<.e is not redistri<uted on
AJ@S
P. 9or "ar#e "ist o! va"ues/ avoid usin# IN KNOT IN in SQ*s. %rite "ar#e "ist
va"ues to a temporary ta"e and use this ta"e in the +uery
Q. Ja&e sure when to use eCistsKnot eCists condition since they i#nore
un&nown comparisons ,e8. 6 NI** va"ue in the co"umn resu"ts in un&nown- .
Hence this "eads to inconsistent resu"ts
O. Inner Ls Outer *oins
(hec& which >oin wor&s eHcient"y in #iven scenarios.Some e8amp"es are
6 'uter >oins can e used in case o! "ar#e ta"e >oinin# with sma"" ta"es ,"i&e
!act ta"e >oinin# with Aimension ta"e ased on re!erence co"umn-
6 Inner >oins can e used when we #et actua" data and no e8tra data is
"oaded into spoo" !or processin#
Please note for outer join conditions:
.. 9i"ter condition !or inner ta"e shou"d e present in ?'N? condition
0. 9i"ter condition !or outer ta"e shou"d e present in ?%HE)E? condition
Ran3 vs RowTNu+<er in Teradata
Anyone wor&in# on Teradata wou"d e aware o! the two most common '*A@
!unctions in Teradata which are used !or common use i.e.
1. )an&,-
2. )ow:Numer,-
In one o! my posts I have mentioned aout how to #enerate se+uence
numer ,e8. Surro#ate 7ey- usin# )ow:Numer. Today "et us 1nd out the
diBerence in usa#e o! ran& and row numer !unctions y ta&in# !o""owin#
scenario on ta"es ,sa"es:dai"y-
SELECT
item:id/
sa"es:date/
Actua":sa"es/
)AN7,- 'WE) ,OR"ER B! Actua":sa"es "ESC- / --
RANK function
)'%:NIJBE),- 'WE) ,OR"ER B! Actua":sa"es "ESC- --
ROW_NUMER function
)ROM Sa"es:dai"y
%&ERE
sa"es:date BET%EEN AATE ;04.464.64.; AN" AATE ;04.464M64.;5
T=e resu.t set is as >o..ows:
Ite+Tid
Sa.esTdat
e
Actua.Tsa
.es Ran3
RowTNu+<
erGI
.04 P/./04.4 QQ4 4 .
.04 P/0/04.3 QQ4 4 0
.04 P/0/0404 PQ4 M M
.04 P/0/044O MQ4 P P
.04 P/0/0403 MQ4 P Q
.04 P/./044Q MQ4 P O
.04 P/./044M 0Q4 3 3
.04 P/0/044M 0Q4 3 \
.04 P/./040Q 044 X X
.04 P/./0440 044 X .4
.04 P/./040. .Q4 .. ..
.04 P/0/044. .Q4 .. .0
.04 P/./044. .Q4 .. .M
.04 P/./.XM. .44 .P .P
In the resu"t set/ we can oserve the !o""owin#/
.- )ows . and 0 have same ran& assi#ned since that have same
actua.Tsa.es va"ue
0- )ows . and 0 have diBerent row numers assi#ned even thou#h
same actua.Tsa.es va"ue
M- )ow M has ran& DOE assi#ned as ran&in# positions
Hence /
rows are a"ways assi#ned an incremented se+uence numer with
)'%:NIJBE).
)ows are a"ways assi#ned the same numer with )AN7 !unction.
Anyone wor&in# on Teradata wou"d e aware o! the two most common '*A@
!unctions in Teradata which are used !or common use i.e.
In the resu"t set/ we can oserve the !o""owin#/
.- )ows . and 0 have same ran& assi#ned since that have same
actua.Tsa.es va"ue
0- )ows . and 0 have diBerent row numers assi#ned even thou#h
same actua.Tsa.es va"ue
M- )ow M has ran& DOE assi#ned as ran&in# positions
Hence /
rows are a"ways assi#ned an incremented se+uence numer with
)'%:NIJBE).
)ows are a"ways assi#ned the same numer with )AN7 !unction.
&ow to se.ect Nt= row >ro+ a ta<.e 9
=ow to se.ect a ,articu.ar row >ro+ t=e ta<.e9
Ans:
By usin# )'%:NIJBE),- 9unction / we can mar& a"" the se"ected rows with
numers .
Then use QIA*I9C c"ause to #et e8cat row numer.
se"ect
co"umnA/co"umnB
!rom
source:ta"e
+ua"i!y row:numer,- over ,order y co"umnA - $ Nth record 5
Here ;N; ein# particu"ar row numer.
P(S: The same +uery can e used to se"ect Top N records5
se"ect
co"umnA/co"umnB
!rom
source:ta"e
+ua"i!y row:numer,- over ,order y co"umnA - 2$ N5
&ow to ;enerate row nu+<ers in teradata9
%e have come across rownum !unction in orac"e . This !unction #ives numer
!or every
row/record in 'rac"e. In teradata there is no direct approach "i&e in orac"e.
There are various
approaches su##ested around.
A,,roac= 4:
Here Sum !unction is used over rows precedin# in the S'I)(E:TAB*E
Se"ect sum,.- over, rows unounded precedin# -/ co"umnA/ co"umn !rom
S'I)(E:TAB*E5
A,,roac= 8:
Here )'%:NIJBE) !unction is used to #enerate row:numer on co"umnA
se"ect
)'%:NIJBE),- over, ')AE) BC co"umnA -/
co"umnA/
co"umnB
!rom
S'I)(E:TAB*E5
I! you have to use the row numer concept in tar#et ta"e as we""/ then
!o""owin# approach usin# Ridentit@ co.u+nR ,!rom W0)O onwards - e used
K
()EATE JI*TISET TAB*E TA)FET:TAB*E
,
co"umnA INTEFE) FENE)ATEA BC AE9AI*T AS IAENTITC
,STA)T %ITH .
IN()EJENT BC 04- /
co"umnB WA)(HA),04- N'T NI**
-
INIQIE @)IJA)C INAEL pid8 ,(o"A-5
P(S: Identity co"umns does diBer !rom se+uence concept in orac"e. The
numers assi#ned in these co"umns are not #uaranteed to e se+uenctia".
The Identity co"umn in Teradata is used to #uaranteed row6uni+ueness.
This wor&s without use o! Identity approach.
create TAB*E TA)FET:TAB*E as
,
se"ect )'%:NIJBE),- over, ')AE) BC co"umnA - NIJBE):SEQ /
co"umnA/
co"umnB/ co"umn( !rom a >oin on a.id$.id
- with data 5
Co..ect stats
'ne o! my !avorite commands and most use!u" amon# the "ot / is Aia#nostic
he"p stats .
This command is very use!u" in he"pin# user understand which a"" co"umns
shou"d have co""ect
stats e co""ected on/ so optimiUer can se"ect the est p"an.
To Inc.ude t=e Stats co..ection reco++endations in t=e eC,.ain
,.an(
AIAFN'STI( HE*@STATS 'N 9') SESSI'N5
At the end o! the e8p"ain te8t is the recommended statistics !or co""ection wi""
e as !o""ows
/*BEFIN )E('JJENAEA STATS 6G
.O- ?('**E(T STATISTI(S AA%.@)'AI(T ('*IJN @:SIYE?. ,Hi#h(on!-
.3- ?('**E(T STATISTI(S AA%.@)'AI(T ('*IJN @:('AE?. ,Hi#h(on!-
.\- ?('**E(T STATISTI(S AA%.@)'AI(T ('*IJN @:AES(?. ,Hi#h(on!- */
I! you want e8p"ain to stop showin# recommendations !or co""ection o! stats/
then use the !o""owin#
AIAFN'STI( HE*@STATS N'T 'N 9') SESSI'N5
"ia;nostic =e., stats =as so+e draw<ac3s .i3e
It does not #ive any sort o! indication o! sta"e stats
Stats shou"d e chosen care!u""y as recommended y dia#nostic he"p
stats
(are shou"d e ta&en to see that too many stats on a #iven ta"e can
impact atch runnin# o! scripts and increases the over"oad o! stats
maintenance.
I! recommended stats donSt show any improvements in per!ormance/
A)'@ them^
)ABMs on Co..ect statistics
(o""ect stats >ust derives the data demo#raphics o! the ta"e. These
demo#raphics are use!u" !or optimiUer to decide the e8ecution o! #iven +uery
which in turn improves per!ormance.
It co""ects the in!ormation "i&eK
tota" row counts o! the ta"e/
how many distinct va"ues are there in the co"umn/
how many rows per va"ue/ is the co"umn inde8ed/
i! so uni+ue or non uni+ue etc.
%=at i> co..ect stats is not done on t=e ta<.e9
Ans:
Teradata uses a cost ased optimiUer and cost estimates are done ased on
statistics.
So i! you donot have statistics co""ected then optimiUer wi"" use a Aynamic
AJ@ Samp"in#
method to #et the stats. I! your ta"e is i# and data was uneven"y
distriuted then dynamic
samp"in# may not #et ri#ht in!ormation and your per!ormance wi"" suBer.
&ow can i 3now t=e ta<.es >or w=ic= t=e co..ect stats =as <een
done9
Ans:
)un the He"p Stats command on that ta"e.
e.# HE*@ STATISTI(S TAB*E:NAJE 5
this wi"" #ive you Aate and time when stats were "ast co""ected. Cou wi"" a"so
see stats !or the
co"umns , !or which stats were de1ned- !or the ta"e
%=enever co..ect stats is done on t=e ,articu.ar ta<.eGsa@ on
indeCKco.u+nI w=ere can I
-nd in>or+ation re;ardin; t=ese entries 9
Ans:
(o""ected statistics are stored in AB(.TW9ie"ds or AB(.Inde8es ta"es.
However/ these two
ta"es cannot e +ueried .
%=en to co..ect stats on ta<.es w=ic= =ave stats 9
Ans:
.. Typica" #uide"ine is rou#h"y .4< o! the data has chan#ed. ,By
measurin# de"ta in perm space since "ast co""ected.-
0. )eco""ect ased on stats that have a#ed O46X4 days. ,say "ast time stats
co""ected was 0 months a#o- .
P.ease note :
(o""ect stats cou"d e pretty resource consumin# !or "ar#e ta"es. So it is
a"ways advisa"e to
schedu"e the >o at oB pea& period .
EC,ort KI+,ort usin; Teradata SBL assistant
p"ease Ise this option !or !ew reocrds on"y ,say in .444;s- . 9or "ar#e data
vo"umes use !ast"oad ,empty ta"e "oadin#- or J"oad uti"ities
.. *o#in to the Source Aataase usin# Teradata SQ* Assistant. , QA / @)'A-
0. @aste the Source SQ* Query in the ?Query? window.
M. Se"ect the !o""owin# Jenu 'ption ?9i"e$GE8port )esu"ts?
P. Fo to ?Too"s$G'ptions? and se"ect the Aate 9ormat as ;CCCC6JJ6AA;.
@.SK This option is used when a date co"umn e8ists in the ta"e.
Q. )un the Query ,@ress 6 9Q- and @rovide the Tar#et *ocation where you want
the output 1"e to e savedK
O. 'pen the Saved 9i"e ,e8. Test:E8port.t8t- and remove the 9irst *ine !rom
the 9i"e %hich contains a"" the co"umn Names.
3. *o#in to the Tar#et Aataase usin# Teradata SQ* Assistant ,Aev-.
\. Se"ect the !o""owin# Jenu 'ption ?9i"e$GImport Aata?
X. @aste the SQ* Insert Query in the ?Query? window.
e8. Insert into TBEN%:)W*TN:)E@*:*'(:S7I:9% va"ues ,?/?/?/?/?-5
N'TEK There shou"d e a ;?; as a @"ace6Ho"der !or a"" the co"umns in your
Source 9i"e.
.4. )un the Query ,@ress 6 9Q-.
... Turn oB the Import Aata mode and resume +ueryin#.
I+,ortin; ECce. "ata into Teradata Ta<.e
.. Ja&e sure you have the co"umns in E8ce" in the same order as the ta"e
you created. )emove the header rows !rom the E8ce" 1"e and Save the 1"e as
comma de"imited 1"e !rom E8ce" ,(SW 9i"e-.
0. In SQ* Assistant set the Ae"imiter as ?/?,comma- .
, Ae"imiter is avai"a"e in Jenu Too"s / 'ptions/ Import/E8port-
M. Fo to ?Too"s$G'ptions? and se"ect the Aate 9ormat as ;CCCC6JJ6AA;.
@.SK This option is used when a date co"umn e8ists in the ta"e.
P. 9rom Teradata SQ* Assistant/ c"ic& ;9i"e;/ then ;Import Aata;.
Q. )un the commandK insert into TAB*ENAJE va"ues ,?/?/?....-
Cou must supp"y a ? ,+uestion mar&- !or every co"umn. So/ !or a ta"e with Q
co"umns the va"ues command wou"d "oo& "i&eK va"ues ,?/?/?/?/?-.
O. Hi#h"i#ht the insert +uery and @ress 9Q. This wi"" prompt you !or a 1"e
"ocation. Se"ect the appropriate 1"e.
3. This wi"" "oad in the order in which they appear in your te8t 1"e/ which is
why it is important to match the co"umns in E8ce" with the order o! the
co"umns in your ta"e.
\. Turn oB the Import Aata mode and resume +ueryin#.
Stran#e/ ut yes we can ca"cu"ate avera#e on time 1e"ds. (onsider a
scenario in which a ta"e has !o""owin# structure
(ity Jode Start6time end6time
char,.4- char,.4- char,Q-,HHKJI- char,Q-,HHKJI-
666666666666666666666666666666666666666666666666666666666666666666
@aris Ta8i 4PKQQ 4XKMM
)ome Ta8i 40K.P 4\KPP
Jadrid Shutt"e 4.K0. 4MK.X
The re+uirement is to ca"cu"ate avera#e end6time !rom the ta"e.
Since end6time is char ,Q-/ this has to e converted into Time !ormat
HHKJIKSS / e!ore ca"cu"atin# the avera#e
%hen A cast is app"ied as !o""ows
cast,end6timebb;K44; as time- and then try to #et an avera#e / %e wi"" #et
!o""owin# error
Error 6 ?inva.id o,eration on an ANSI date-ti+e or interva.?
To 18/ this issue the concept o! interva" is app"ied.
Se.ect (ITC/ av# ,cast,trim,end6time-bb;K44; as interva" hour,P- to second
,4- --
>ro+ T)AWE* ;rou, <@ (ITC 5
Hence/ usin# interva"/ we can override the ANSI time error and ca"cu"ate
avera#e on time 1e"d
Teradata Timestamp tips V tric&s 6 M
Tip.K E8tractin# month !rom date as ;JJJ;
se.ect current:date ,!ormat ;JJJ;-5
Aate
6666
'ct
@"ease use ? se" cast ,,cast,current:date as !ormat ;mmm;-- as char,M--5 ?
whi"e +ueryin# on S+" Assistant,+ueryman-
Tip0K (onvertin# numer o! seconds to Jinutes and Seconds
I! i want to convert the input o! seconds into minutesNseconds/ !o""owin#
+uery is used
e8K M44 seconds 66G 444QK44 or QK44 mins
create ta<.e ta"e.
, second:s inte#er -5
insert into ta"e. ,M44-5
Se.ect second:s * INTE)WA* ;4444K4.; JINITE TO SE('NA >ro+ Ta"e.5
@"ease note that /i! seconds interva" is more then XXXX,appro8 3 days- / it wi""
proa"y resu"t in a ?3PQMK Interva" 1e"d over]ow?.
TipMK (onvertin# numer o! seconds to Jinutes and Seconds
Simi"ar"y / %e can convert seconds to Aay to second !ormat as we""^^
Se.ect second:s* INTE)WA* ;4444 44K44K4.; AAC TO SE('NA >ro+ ta"e.5
This wi"" wor& !or up to 03 years a!ter which it resu"ts in ?3PQMK Interva" 1e"d
over]ow? error.
TipPK How to add/sutract minutes to timestamp^^
@ro"emK To the #iven timestamp va"ue/ how can we add or sutract #iven
minutes.
e8K
Timestamp. Jinutes. )esu"t
04.464.64P 40K.4K4\ ,N- MM4 $ 04.464.64P 43KP4K4\
04.464.640 .\K4PKM0 ,6- 0PQ $ 04.464.640 .MKQXKM0
create ta<.e Ta"e:.
,Timestamp. timestamp,4- /Jinutes. inte#er -5
insert into ta"e:. va.ues,;04.464.64P 40K.4K4\;/MM4-5
insert into ta"e:. va.ues,;04.464.640 .\K4PKM0;/0PQ-5
se.ect Timestamp. N ,Jinutes. * interva" ;.; minute- >ro+ ta"e:.5
se.ect Timestamp. 6 ,Jinutes. * interva" ;.; minute- >ro+ ta"e:.5
This is continuation o! !o""owin# topic
httpK//www.teradatahe"p.com/04.4/4\/teradata6timestamp6tips.htm".
Some more tips which mi#ht e use!u" whi"e wor&in# on date and timestamp.
,Queries run and veri1ed on W0)O-
Tip .K Addin; and Su<tractin; "ates in Teradata
se.ect my:date N interva" ;.4; day >ro+ my:ta"e
And e+ua""y to sutract va"ues !rom a dateK
se.ect my:date 6 interva" ;.4; day >ro+ my:ta"e
Tip 0K Ca.cu.atin; t=e .ast da@ in a ;iven +ont=
se.ect add:months,current:date/.- 6 e8tract,day >ro+
add:months,current:date/.-- 5
Tip MK sa;e o> S!STCALEN"AR(CALEN"AR
Teradata provides a handy ca"endar ta<.e >or date "oo&up ca..ed
sys:ca"endar.ca"endar.
sin; this ta<.e you can ca"cu"ate use!u" dates such as wee&endin# dates/
+uarter endin# dates/ etc.
e8amp"e. K 9ind the previous 9riday >ro+ todayK
se.ect * >ro+ sys:ca"endar.ca"endar w=ere day:o!:wee&$O and
ca"endar:date <etween date 6O and date5
e8amp"e0 K9ind the -rst Jonday one wee& a>ter the .ast 9riday o> previous
monthK
se.ect a.ca"endar:date >ro+ sys:ca"endar.ca"endar a/
,
se. ma8,ca"endar:date- N .4 as ca"endar:date
>ro+ sys:ca"endar.ca"endar
w=ere e8tract,year >ro+ add:months, date/ 6.-- $ year:o!:ca"endar
and
e8tract,month >ro+ add:months,date/6.-- $ month:o!:year and
day:o!:wee& $ O
-
w=ere
a.ca"endar:date $ .ca"endar:date5
Tip PK Addin; or Su<tractin; Mont=s

se.ect add:month,date:co"/.- >ro+ ta<.e5 !" addin# of month "!
se.ect add:month,date:co"/6.4- >ro+ ta<.e5 !" su$traction of month "!
Some tips which mi#ht e use!u" whi"e wor&in# on date and timestamp. ,+ueries
run and veri1ed on W0)O-
Tip .K Create Ti+esta+, >ro+ "ate and Ti+e
SELECT CAST,CAST,(I))ENT:AATE AS 9')JAT ;CCCC6JJ6AA;- bb ; ; bb
CAST,CAST,(I))ENT:TIJE AS )ORJAT ;HHKJIKSS;- AS (HA),\-- AS
TIJESTAJ@,4--5
SELECT CAST,(I))ENT:AATE AS TIJESTAJ@,4-- N ,,(I))ENT:TIJE 6 TIJE
;44K44K44;- H'I) TO SE('NA,4--5
Tip 0K Convert ti+esta+, -e.d in Teradata into >or+at MMMM-!!!!M
se.ect (I))ENT:TIJESTAJ@ ,9')JAT ;JJJ6CCCC;-5
(urrent TimeStamp,O-
6666666666666666666
Jar604.4
Tip MK Insertin; currentTti+esta+, va.ue into ti+esta+,GHI co.u+n
Create ta<.e stats,record:time TIJESTAJ@,4--5
%henever we try to popu"ate the current:timestamp va"ue into this co"umn
usin#
insert into stats,record:time- se"ect current:timestamp 5 we #et !o""owin# error.
3PQPK Aate Time 1e"d over]ow.
To avoid this/ we have two so"utions
So"utionsK
.. Aata type !or (I))ENT:TIJESTAJ@ is TIJESTAJ@,O- and you are tryin# to
insert a
TIJESTAJ@,O- data to a TIJESTAJ@,4- and that;s why you are #ettin# this error.
insert into stats,record:time-
Se. cast,(I))ENT:AATE as TimeStamp,4--
N
,,(I))ENT:TIJE 6 time ;44K44K44;- hour to second,4-- 5
0. insert into stats,record:time- se.ect (I))ENT:TIJESTAJ@,4-5
Tip PK Add +inutes to ti+esta+,
How to add .4 minutes to current timestamp in TA?
SEL (I))ENT:TIJESTAJ@ N INTE)WA* ;.4; JINITE.
The !o""owin# e8amp"e is ta&en strai#ht !rom Teradata 9unctions and 'perators
re!erence manua".
E8amp"e .K Sutract two TIJESTAJ@ Types
(onsider the !o""owin# ta"eK
CREATE TABLE Bi""AateTime
,start:time TIJESTAJ@,4-/end:time TIJESTAJ@,4--5
Aetermine the diBerence/ speci!yin# an Interva" unit o! AAC T' SE('NA !or the
resu"tK
SELECT ,end:time 6 start:time- AAC,P- TO SE('NA )ROM Bi""AateTime5
The AAC,P- speci1es !our di#its o! precision/ and a""ows !or a ma8imum o! XXXX
days/ or
Appro8imate"y 03 years.
The resu"t is an Interva" that "oo&s "i&e thisK
Q .OKPXK04.MP4444
Tip QK Convert varc=ar to ti+esta+,
have a co"umn in source strdate. as WA)(HA),0M- and the va"ue ein#
;04.44M.4.\.4.4;.
SELECT CAST ,;04.44M.4.\.4.4; AS TIJESTAJ@,4- 9')JAT
;CCCCJJAAHHJISS;-5
Tip OK "is,.a@ Ti+esta+, wit= AM KPM >or+at
SELECT CAST,TIJESTAJ@;04.464M6.0 .PKM0KPQ; AS 9')JAT
;yyyymmddhhKmiKsst;- ,char,04--5
Tip 3K "is,.a@ ti+esta+, in 88 Mar 8H4H HH:86:6:(U:H >or+at
se.ect cast,current:TIJESTAJ@,M- as timestamp,M- 9')JAT
;ddmmmyyyyhhKmiKss.s,M-;-,char,0Q--5
Tip \K Su<tract two TIMESTAMP T@,es
(onsider the !o""owin# ta"eK
CREATE TABLE Bi""AateTime ,start:time TIJESTAJ@,4-/end:time TIJESTAJ@,4-
-5
Aetermine the diBerence/ speci!yin# an Interva" unit o! AAC T' SE('NA !or the
resu"tK
SELECT ,end:time 6 start:time- AAC,P- TO SE('NA )ROM Bi""AateTime5
The AAC,P- speci1es !our di#its o! precision/ and a""ows !or a ma8imum o! XXXX
days/ or
Appro8imate"y 03 years.
The resu"t is an Interva" that "oo&s "i&e thisK
Q .OKPXK04.MP4444
Tip XK ECtract >unction on "ATE N TIME
ECtractin; )ro+ Current "ateGJarch 04/04.4-
[ Buer@ Resu.t
SELECT AATE5 .4/4M/04 ,"e>au.t
!ormat-
SELECT ELT)A(T,CEA) )ROM AATE-5 04.4
SELECT ELT)A(T,J'NTH )ROM AATE-5 4M
SELECT ELT)A(T,AAC )ROM AATE-5 04
SELECT ELT)A(T,CEA) )ROM AATE N MOQ-5 04..
SELECT ELT)A(T,J'NTH )ROM AATE N M4-5 4P
SELECT ELT)A(T,AAC )ROM AATE N .0-5 4.
ECtractin; )ro+ Current Ti+e G 0KP0 @J -
Buer@ Resu.t
SELECT TIJE5 .PKP0KM0 ,"e>au.t
!ormat-
SELECT ELT)A(T,H'I) )ROM TIJE-5 .P
SELECT ELT)A(T,JINITE )ROM TIJE-5 P0
Loc3in; ta<.e >or access9
%e wou"d have come across this statement in many +ueries which are run
in sensitive environments "i&e @)'A/ IAT. They can e used with views or
sometimes >ust !or +ueryin# purpose.
I wanted to discuss how important this statement wou"d e in rea"6time
/active data warehouses where "ot o! users wi"" e stri&in# +ueries on same
dataase at the time.
create view Emp"oyee.view:emp"oy:with*oc&
as
.oc3in; ta<.e Emp"oyee.Aept:emp >or access
se.ect *
>ro+ Emp"oyee.Aept:emp 5
By usin# "oc&in# ta"e !or access/ we ma&e sure that norma" ?access? "oc& is
app"ied on ta"e which is re+uired to !etch resu"ts. By doin# so /
6 There is no waitin# !or other "oc&s to re"ease since access "oc& can e
app"ied on ta"e which has read/write "oc& app"ied to it
6 This wi"" cause the +uery to e8ecute even when some "oc& is app"ied / ut
accessin# data usin# this "oc& mi#ht not e consistent as it mi#ht resu"t in
dirty read due to concurrent write on the same ta"e.
It is a"ways su##ested to use D"oc&in# ta"e !or access? which since they wi""
not "oc& the other users !rom app"yin# read/write "oc& on the ta"e.
How to E8port without >un& characters in 9astE8port?
So.ution4: Create a s+a.. OTMO" to stri, oF t=e two-<@te
LARC&AR .en;t= -e.d(
So.ution8: Anot=er a.ternative i> @ou are in a NI# environ+ent is to
use A%$ or SE" or CT t=e -.e a>ter it =as <een out,ut to stri, t=e
.eadin; to c=aracters >ro+ eac= record(
STEP1: rite t!e "uer# in $%STE&P'(T )le as follo*s
SE*E(T ;b;bb(o".bb;5;bb(o"0 !rom TAB.5 66 Here ;b; pipe operator is used as
de"imiter.
So resu"t #enerated wi"" e as !o""ows
VAb(o".5(o"0
?VA? is a >un& va"ue #enerated durin# EL@')T.
STEP2: rite +NI& scri,t and ,ass )lename as )rst ,arameter
ZZZZZINIL S'*ITI'N ZZZZZZZZZZZZZ
ZZcreate a 1"e trim.&sh ZZZZZZZZZZZZ
ZZ )un the 1"e trim.&sh 2user:1"enameGZZZ
9i"eName$c.
cat c9i"eName b cut 6!06 6d ;b; G c9i"eName.tmp
mv c9i"eName.tmp c=oin:E8port.t8t.
The )esu"t a!ter cuttin# a"" >un& characters ti"" occurrence o! @I@E operation
wi"" e as !o""ows
(o".5(o"0
So.ution O: <@ castin; Entire resu.t to C&AR
%hen we are e8portin# a ta"e in record mode / @"ease ma&e sure that data
e8ported does not contain e8tra 0 characters y castin# entire resu"t to
(HA),-.
9or e8amp"eK i! ta"e. has 0 co"umns/ (o". is o! type char ,O-/ (o"0 is o! type
char ,0-
%rite the +uery as !o""owsK
Se"ect cast ,c. bb c0- as char ,\- !rom ta"e.5
Note: I! we write +uery "i&e Dse.ect c4 WW c8 >ro+ ta<.e4?/
The records e8ported wi"" contain 0 yte "en#th at the e#innin#/ ecause
concatenation returns LARC&AR GI type not (HA) ,- type.
AiBerence etween count,*- and count,.- ?
(ount is one o! very important !unctions used in any dataase . But what
many dont &now that is the resu"t count we #et !rom ('INT !unction mi#ht
e diBerent ased on how it is used. *et us consider the e8amp"e o! count,*-
and (ount,.- and understand how there is some diBerence the usa#e.
Say !or a #iven ta"e with data
L y
666666666666
0. M.
Nu"" M0
Nu"" MM
P. MP
Nu"" Nu""
And this +ueryK
se"ect count,*-/ count,8-/ count,.- !rom ta"e5
)esu"tsK P/ 0/ P
* (ount,*- counts a"" occurrences inc"udin# nu""s. This is a row count !or a
#iven ta"e.
* (ount,8- counts a"" non nu"" occurrences o! va"ues in co"umn 8. I! 8 has nu""
va"ues/ count,8- wi"" e "ess than count,*-.
* (ount,.- is simi"ar to count,8- .It counts a"" nu"" va"ues in a ?pseudo
co"umn? created y the constant. Since the constant . wi"" never e nu""/ this
wou"d/ e "i&e count,*- i.e row count .
*ist o! use!u" Aata dictionary views which mi#ht come in handy in situations^
.. AB(.users
This view #ives current user in!ormation
0. dc.sessionin!o
This view #ives in!ormation aout
6 detai"s o! users current"y "o##ed in
M.AB(.Aataases
This view "ist a"" the dataases present in the #iven teradata dataase
system. A*so contains use!u" in!ormation "i&e
6(reatorname
6'%nername
6@E)Jspace
6S@''*space
6TEJ@space
P.AB(.Indices
It #ives in!ormation on the inde8 created !or #iven ta"e
Q.AB(.Ta"es
It #ives in!ormation aout a"" the Ta"es,T-/ views,W-/ macros,J-/ tri##ers,F-/
and stored procedures .
O.AB(.Inde8(onstraints
It @rovides in!ormation aout partitioned primary inde8 constraints.
;Q; indicates a ta"e with a @@I
3. AB(.Ais&Space
It provides in!ormation aout dis& space usa#e ,inc"udin# spoo"- !or any
dataase or account.
SELECT AataaseName
/CAST ,SIJ ,Ja8@erm- AS 9')JAT ;UUU/UUU/UUX;-
/CAST ,SIJ ,(urrent@erm- AS 9')JAT ;UUU/UUU/UUX;-
/CAST ,,,SIJ ,(urrent@erm--/
NI**I9YE)' ,SIJ,Ja8@erm-- * .44-
AS )ORJAT ;UUX.XX<;- AS ?< Ised?
)ROM AB(.Ais&Space
'ROP B! .
OR"ER B! P "ESC 5
\. AB(.Ta"eSiUe
It provides in!ormation aout dis& space usa#e ,e8c"udin# spoo"- !or any
dataase/ ta"e or account
SELECT Wproc
/CAST ,Ta"eName
AS 9')JAT ;L,04-;-
/(urrent@erm
/@ea&@erm
)ROM AB(.Ta"eSiUe
%&ERE AataaseName $ SER
OR"ER B! Ta"eName/ Wproc 5
X. AB(.A""Space
It provides in!ormation aout dis& space usa#e ,inc"udin# spoo"- !or any
dataase/ ta"e/ or account.
SELECT Wproc
/CAST ,Ta"eName AS
9')JAT ;L,04-;-
/Ja8@erm
/(urrent@erm
)ROM AB(.A""Space
%&ERE AataaseName $ SER
OR"ER B! Ta"eName/ Wproc 5
.4. AB(.co"umnstats / AB(.inde8stats and AB(.Ju"tico"umnstats
These are used to 1nd stats in!o on #iven ta"es
"iFerence <etween Create ta<.e Gco,@I and Create ta<.e Gse.ectI
%hen ever we need to create a copy o! e8istin# ta"e we tend to use create
ta"e,copy - !rom e8istin# ta"e or (reate ta"e , se"ect- !rom e8istin# ta"e.
Jany may i#nore the diBerence in runnin# o! create ta"e in two diBerent
ways assumin# the structure created to e same. But in actua" case/ it is
not so^^
"et us try out two type o! create ta"e types usin# e8amp"es to understand
the diBerences.
(reate a ta"e (hec&.0M which inc"ude not nu"" /de!au"t /I@I and ISI
de1nations in it
S&O% TABLE chec&.0M5
/*
()EATE SET TAB*E chec&.0M /N' 9A**BA(7 /
N' BE9')E ='I)NA*/
N' A9TE) ='I)NA*/
(HE(7SIJ $ AE9AI*T
,
int. INTEFE) "E)ALT 4 /
int.0 INTEFE) NOT NLL "E)ALT 4 /
int0 INTEFE) NOT NLL/
intM INTEFE) NOT NLL-
NIBE PRIMAR! IN"E# ,ri+4 G intO I
NIBE IN"E# uniq4 G int8 I5
*/

Ste,4: Create ta<.e C=ec3TCOP! >ro+ C=ec348O usin; CREATE
TABLE GCOP! I +et=od
CREATE TABLE chec&:('@C AS chec&.0M %IT& no data 5
)un show ta"e command to chec& !or ta"e structure
S&O% TABLE chec&:('@C5
/*
()EATE SET TAB*E chec&:('@C /N' 9A**BA(7 /
N' BE9')E ='I)NA*/
N' A9TE) ='I)NA*/
(HE(7SIJ $ AE9AI*T
,
int. INTEFE) "E)ALT 4 /
int.0 INTEFE) NOT NLL "E)ALT 4 /
int0 INTEFE) NOT NLL/
intM INTEFE) NOT NLL-
NIBE PRIMAR! IN"E# ,ri+4 G intO I
NIBE IN"E# uniq4 G int8 I5
*/
9rom the !o""owin# oservation we can understand that the ta"e created
usin# ('@C method wi"" retain a"" datatypes and inde8 de1nations "i&e I@I
and NI@I
Ste,8: Create ta<.e C=ec3TSELECT >ro+ C=ec348O usin; CREATE
TABLE GCOP! I +et=od
CREATE TABLE (hec&:SE*E(T AS
, se" * )ROM chec&.0M - %IT& no data 5
)un show ta"e command to chec& !or ta"e structure
S&O% TABLE (hec&:SE*E(T5
/*
()EATE SET TAB*E (hec&:SE*E(T /N' 9A**BA(7 /
N' BE9')E ='I)NA*/
N' A9TE) ='I)NA*/
(HE(7SIJ $ AE9AI*T
,
int. INTEFE)/ --"E)ALT MISSIN'
int.0 INTEFE)/ -- "E)ALT and NOTNLL MISSIN'
int0 INTEFE)/ -- NOTNLL MISSIN'
intM INTEFE)- -- NOTNLL MISSIN'
@)IJA)C INAEL , int. -5
*/
Hence when ta"e is created usin# CREATE TABLE usin; SELECT !rom
ta"e method/ the ta"e created wi"" not retain !o""owin# !rom ori#ina" ta"e
AE9AI*T
N'T NI**
INIQIE @)IJA)C INAEL
INIQIE INAEL
distinct vs #roup y in Teradata .
There is a"ways a deate #oin# on when 1ndin# out uni+ue va"ues in a #iven
ta"e. The pro"em comes into picture when we use Froup y or distinct to
1nd it.
Both return same numer o! rows / ut with some e8ecute time diBerence
etween them. E8ecution time is a"ways a very important !actor considerin#
per!ormance as one o! the ma>or !actors is teradata warehouse.
So which is more eHcient ?? AISTIN(T or F)'I@ BC???
Since AISTIN(T redistriutes the rows immediate"y/ more data may move
etween the AJ@s/ where as F)'I@ BC that on"y sends uni+ue va"ues
etween the AJ@s.
So/ we can say that F)'I@ BC sounds more eHcient.
But when you assume that data is near"y uni+ue in a ta"e/ F)'I@ BC wi""
spend more time attemptin# to e"iminate dup"icates that do not e8ist at
a"".There!ore/ it is wastin# its time to chec& !or dup"icates the 1rst time.
Then/ it must redistriute the same amount o! data .
*et us see how these steps are used in each case !or e"imination o!
Aup"icates
,can e !ound out usin# e8p"ain p"an-
AISTIN(T
.. It reads each row on AJ@
0. Hashes the co"umn va"ue identi1ed in the distinct c"ause o! se"ect
statement.
M. Then redistriutes the rows accordin# to row va"ue into appropriate AJ@
P. 'nce redistriution is comp"eted / it
a. Sorts data to #roup dup"icates on each AJ@
. %i"" remove a"" the dup"icates on each amp and sends the
ori#ina"/uni+ue va"ue
@.sK There are cases when ?Error : 86:6 No +ore S,oo. S,ace ? . In such
cases try usin# F)'I@ BC.
F)'I@ BC
.. It reads a"" the rows part o! F)'I@ BC
0. It wi"" remove a"" dup"icates in each AJ@ !or #iven set o! va"ues usin#
?BI(7ETS? concept
M. Hashes the uni+ue va"ues on each AJ@
P. Then it wi"" re6distriute them to particu"ar /appropriate AJ@;s
Q. 'nce redistriution is comp"eted / it
a. Sorts data to #roup dup"icates on each AJ@
. %i"" remove a"" the dup"icates on each amp and sends the
ori#ina"/uni+ue va"ue
Hence it is etter to #o !or
F)'I@ BC 6 when Jany dup"icates
AISTIN(T 6 when !ew or no dup"icates
F)'I@ BC 6 S@''* space is e8ceeded
Teradata HE*@ commands
Teradata provides one o! the user !riend"y !eatured "i&e HE*@ commands.
*et us see the various he"p commands and their uses.
&ELP SESSION5
This command is used to disp"ay the user name/ account name/ "o#on date
and time/ current dataase name/ co""ation code set and character set ein#
used and a"so / transaction semantics/ time Uone and character set data.
&ELP "ATABASE 0data<ase-na+e1 5
This command is used to disp"ay the names o! a"" the ta"es ,T-/ views ,W-/
macros ,J-/ and tri##ers ,F- stored in a dataase and ta"e comments
&ELP SER 0user-na+e1 5
This command is used to disp"ay the names o! a"" the ta"es ,T-/ views ,W-/
macros ,J-/ and tri##ers ,F- stored in a user area and ta"e comments
&ELP TABLE 0ta<.e-na+e1 5
This command is used to disp"ay the co"umn names/ type identi1er/ and any
user written comments on the co"umns within a ta"e.
&ELP LOLATILE TABLE 5
This command is used to disp"ay the names o! a"" Wo"ati"e temporary ta"es
active !or the current user session.
&ELP LIE% 0view-na+e1 5
This command is used to disp"ay the co"umn names/ type identi1er/ and
comments on the co"umns within a view.
&ELP MACRO 0+acro-na+e1 5
This command is used to disp"ay the characteristics o! parameters passed to
it at e8ecution time.
&ELP TRI''ER 0tri;;er-na+e1 5
This command is used to disp"ay detai"s created !or a tri##er/ "i&e action time
and se+uence.
&ELP PROCE"RE 0,rocedure-na+e1 5
This command is used to disp"ay the characteristics o! parameters passed to
it at e8ecution time.
&ELP COLMN 0ta<.e-na+e1(X OR &ELP COLMN 0view-na+e1(X
OR &ELP COLMN 0ta<.e-na+e1(0co.u+n-na+e12 (Y5
This command is used to disp"ay detai" data descriin# the co"umn "eve"
characteristics.
&ELP IN"E# 0ta<.e-na+e1 5
This command is used to disp"ay the inde8es and their characteristics "i&e
uni+ue or non6uni+ue and the co"umn or co"umns invo"ved in the inde8. This
in!ormation is used y the 'ptimiUer to create a p"an !or SQ*.
&ELP STATISTICS 0ta<.e-na+e1 5
This command is used to disp"ay va"ues associated with the data
demo#raphics co""ected on the ta"e. This in!ormation is used y the
'ptimiUer to create a p"an !or SQ*.
&ELP CONSTRAINT 0ta<.e-na+e1(0constraint-na+e1 5
This command is used to disp"ay the chec&s to e made on the data when it
is inserted or updated and the co"umns are invo"ved.
&ELP MSBLM5
This command is used to disp"ay a "ist o! a"" avai"a"e SQ* commands and
!unctions.
&ELP MSBL 0co++and1M5
This command is used to disp"ay the asic synta8 and options !or the SQ*
command used in p"ace o! the 2commandG.
&ELP MSPLM5
This command is used to disp"ay a "ist o! avai"a"e S@* commands.
&ELP MSPL 0co++and1M5
This command is used to disp"ay the asic synta8 and options !or the S@*
command used in p"ace o! the 2commandG.
9ind co"umn type usin# ui"t in !unction^^^
Aid you &now that datatype o! co"umn cou"d e !ound usin# a ui"t in
!unction ca""ed ?TC@E? .
Ti"" I came across this !unction/ I used to !o""ow the ancient method o!
di##in# into Aata Aictionaries,dc.co"umns- to 1nd the type o! #iven
co"umn.
There are some cases in which peop"e use (ASE !unction to 1nd the
match !or type o! the co"umn and ased on which they do e8ecute
steps.
E(;: (hec& !or co"umn as timestamp / i! yes e8tract date or so...
To avoid usa#e o! dc.co"umns ta"e / we can use Type,(o"umn Name-
!unction
SE*E(T TC@E,TAB..('*.-5
Type,('*.-
66666666666
INTEFE)
(an i Fenerate random numers in Teradata?
There is a scenario in which I need to #enerate )ANA'J numers !or a #iven
co"umn ,inte#er -. In teradata we can use a !unction ca""ed as
)ANA'J,min:va"ue/ ma8:va"ue- .
This is imp"emented in s+" as !o""ows.
Se"ect )ANA'J,./Q44- !rom ta"e5
P.ease note: There mi#ht e cases where )andom !unction can
produce dup"icate va"ues. S' whi"e desi#nin# ta"es / ma&e sure that
the co"umn ma&in# use o! )ANA'J is not part o! INIQIE @)IJA)C
INAEL
which is !aster ? se"ect * !rom ta"e or se"ect ;a"" (o"umns; !rom ta"e ??
Jany o! us wou"d have come across a scenario where "istin# co"umn names
in se"ect SQ* was !ound to e !aster then usin# se"ect * !rom ta"e
command . This indeed is interestin# .
The reason ein# /
In case o! usin# Rse.ect X >ro+ ta<.eR / A e8tra sta#e is added where * is
rep"aced y co"umn names y teradata and then it wou"d !etch the data .
But usin# Rse.ect 0a.. Co.u+ns 1 >ro+ ta<.e R e"iminates this e8tra sta#e
o! veri!yin# and !etchin# on co"umns !rom the ta"e.
Hence it is a"ways recommended to use ?se"ect 2a"" (o"umns G !rom ta"e ?
&ow to Convert co.u+n data to rows in teradata
Pro<.e+ :
There is a re+uirement to convert co"umn data into rows.
(onsider the country ta"e with data as !o""ows
Ta"e has P co"umns ,country / va"ue./va"ue0/va"ueM-
NY Q4 O4 34
AIS ..4 .04 .M4
The output shou"d e disp"ayed in !o""owin# manner
countr@ va.ue
NY Q4
NY O4
NY 34
AIS ..4
AIS .04
AIS .M4
Resu.tin; quer@:
se"ect country/ va"ue. as va"ue !rom T:country
union a""
se"ect country/ va"ue0 as v !rom T:country
union a""
se"ect country/ va"ueM as v !rom T:country5
There mi#ht e various approaches to this pro"em.Inion was !ound out to
e eHcient and served the purpose.
Jateria"ised view in teradata? Is it possi"e?
Jost o! the dataases uses concept o! materia"ised views ,which stores data
-. Sad"y/ in case
o! teradata there is no such concept o! materia"ised views.
The c"osest option o! havin# materia"sed view in case o! teradata is y usin#
='IN inde8 ,or
a##re#ate inde8- . A view can e created on >oin INAEL . The command
used to create inde8
is as !o""ows
?()EATE ='IN INAEL...,Se"ect ta"e options-?.
%hen =oin Inde8 is e8ecuted/ it stores data as a ta"e in spoo" space/ hence
ma&in# the >oin
much !aster
P.ease Note:
There are drawac&s on =oin Indices.
.. 'ptimiUer wou"d determine whether The inde8 is ene1cia". I! yes then it
invo&es it^
0.As the >oin inde8 cannot e accessed direct"y and a view is created that
"oo&s "i&e the >oin inde8 . However/ this approach does not #uarantee that
the >oin inde8 wi"" e used when view is ca""ed.
Pur,ose o> CASESPECI)IC in teradata
(asespeci1c !unction in teradata is used to #et e8cat va"ue say !or e8amp"e
.product code ;)ac.0MSa; .
SE*E(T product:code
9)'J product:ta
%HE)E product:code ,(ASES@E(I9I(- *I7E ;<)a<;5
NoteK Isua""y the comparison in teradata is not case6speci1c. To en!orce
(ASES@E(I9I( / we use (ASES@E(I9I( !unction
&ow to s,.it source co.u+n into +u.ti,.e tar;et co.u+ns G >u.. na+e
to -rst and LastI
ApproachK
CREATE SET TABLE test
,
!u""name varchar,M4-
-5
INSERT INTO test.0 ,;nitin ra>;-5
INSERT INTO test.0 ,;nitin a#arwa";-5
INSERT INTO test.0 ,;ahishe& #upta;-5
se" * )ROM test5
)u..na+e
nitin
a#arwa"
nitin ra>
ahishe&
#upta
Ise inde8 to 1nd the position o! space ?S@A(E? in !u"" name and then use the
position to #et
66G 1rstname $!u""name !rom .st ti"" ,S@A(E6.-
66G"astname $ !u""name !rom ,S@A(EN.-
SELECT IN"E#,!u""name /; ;- AS ?a?/ SBSTR,!u""name/./ a6. - /
SBSTR,!u""name/aN. - )ROM test5
a
Su<strG>u..na+e242
Ga-4II
Su<strG>u..na+e2
aI
ONitin a#arwa"
ONitin ra>
XAhishe& #upta
How can you view Aata Aistriution in Teradata ?
Teradata uses HASH va"ues to store data in AJ@s. To view data distriution
we use Hash 9unctions.
Hash !unctions are usua""y used over primary inde8 co"umns to 1nd data
distriution . %e can identi!y s&ewness y usin# this concept .
9o""owin# +uery can e used to 1nd hash va"ues o! @I co"umns
SE*E(T HASHAJ@,HASHBI(7ET,HASH)'%,2@)IJA)C INAELG--- AS
?AJ@Z?/('INT,*-
9)'J 2TAB*ENAJEG
F)'I@ BC .
')AE) BC 0 AES(5
By "oo&in# at resu"t / you +uery you can easi"y 1nd out the Aata Aistriution
across a"" AJ@s in your system and !urther you can easi"y identi!y un6even
data distriution.
de-nitions :
HASH)'% 6 returns the row hash va"ue !or a #iven va"ue
HASHBI(7ET 6 the #roupin# o! a speci1c hash va"ue
HASHAJ@ 6 the AJ@ that is associated with the hash uc&et
How to chec& !or ta"e siUe in Teradata
The !o"""owin# +ueries are used to chec& !or ta"esiUe in Teradata
How can you 1nd the Ta"e Space SiUe o! your ta"e across a"" AJ@s ?

SE*E(T AATABASENAJE/ TAB*ENAJE/ SIJ,(I))ENT@E)J-
9)'J AB(.TAB*ESIYE
%HE)E AATABASENAJE $ ;0"ATABASETNAME1;
ANA TAB*ENAJE $ ;0TABLETNAME1;
F)'I@ BC AATABASENAJE / TAB*ENAJE5
9o""owin# +uery wi"" #ive the space consumed on each AJ@ y the Ta"e
SE*E(T AATABASENAJE/ TAB*ENAJE/ (I))ENT@E)J
9)'J AB(.TAB*ESIYE
%HE)E AATABASENAJE $ T0"ATABASETNAME1;
ANA TAB*ENAJE $ ;0TABLETNAME1 ;5
S,eci-c to ,roDect:
..%here did you use the concurrency?
0.%hen is concurrency introduced in the app"ication ,%hen the threads are
created-?
M.How do you synchroniUe mu"tip"e re+uests !or mu"tip"e %or& stations?
P.%hy separate thread is created !or readin# and writin#?
Q.How do you read and write ,%hich !unction do you use- i! there is on"y one
thread !or readin# and writin#?
O.To which operation you #ive priority/ read or write i! a soc&et is read !or
readin# as we"" as writin#?
3.I! read is #iven priority where do you store your data to e written?
\.How much com!orta"e you are with (/ (NN?
X.How do you rate on the sca"e o! .4 !or (?
.4.%hich compi"er did you use?
Tec=nica. Buestions:
C:
..%hat is se"ect?
0.%hat is po""?
M.How do you create thread?
P.%hich "irary you "in& with when you use pthreads?
Q.How do you create process?
O.How many times !or&,- returns? %hat are the va"ues?
3.%hat is the diBerence etween !or&,- and e8ec,- system ca""s?
.4.Ao you &now readers writer pro"em?
...Ta&e a data structure and synchroniUation mechanism and so"ve ,write
code !or- the readers writer ,in !act they as&ed !or mu"tip"e writers-?
.0.%hy did you use whi"e instead o! i! when chec&in# !or the !u""/empty
condition ,in so"ution to the readers writer pro"em-?
.M.%hat are the diBerences etween a process and a thread?
.P.%hat are the thin#s that thread doesnSt share with process?
.Q.%hy there is separate stac& !or each thread?
.O.%hat is !open?
.3.%hat is the diBerence etween !open and open?
.\.%hat is the diBerence etween hi#h "eve" !unctions and "ow "eve"
!unctions?
.X.%hat open returns?
04.Aescriptors returns y the open wi"" e in se+uence? =usti!y?
0..%hy open doesnSt return 4 or . or 0?
00.How do you 1nd siUe o! a 1"e?
0M.%hat is !stat?
0P.%hat are diBerent options avai"a"e with cc
0Q.%hat an output 1"es contains?
"ata<ase Conce,ts:
..%hat is )ABJS?
0.%hat is re!erentia" inte#rity?
M.%hat are A(IA properties?
P.%hat is a transaction?
Q.)e"ate atomicity in transaction de1nition?
O.%hat is a primary &ey?
3.%hat is a !orei#n &ey?
"ata Structures:
..Ao you &now data structures? How !ar?
0.Ao you &now Binary tree?
M.%rite a code !or chan#in# a tree into mirror ima#e o! itse"!? Trace it !or
#iven input?
P.Ao you tree traversa" techni+ues? %hat are the diBerent traversa"s
techni+ues?
Q.Ao you &now inary search trees? E8p"ain?
O.Arran#e the #iven input ,se+uence o! numers- in to a inary search tree?
SBL:
..%rite a +uery to disp"ay avera#e sa"ary o! a"" emp"oyees in EJ@
department numer wise?
0.%rite a +uery to disp"ay avera#e sa"ary o! a"" emp"oyees in EJ@
department name wise?
M.%rite a +uery to de"ete a row !rom a parent ta"e i! no re"ated row is
present in correspondin# chi"d ta"e? Ta&e e8amp"e o! EJ@ and AE@T ta"es?
NI#:
..Te"" aout virtua" memory and pa#in#?
0.%hat is !ra#mentation?
M.Ao you &now INIL interna"s?
P.%hat are ma&e1"es?
Q.%rite a sma"" samp"e ma&e1"e?
O.%hich deu##er did you use?
CZZ:
..How virtua" !unctions concept is imp"emented interna""y? E8p"ain with short
code?
0.%hat are pure virtua" !unctions?
M.%hen do you use pure virtua" !unctions?
P.%here do you use dynamic:cast?
Q.%hat is )TTI?
O.How do you identi!y the type dynamica""y?
3.%hat are the other casts avai"a"e in (NN?
S=e.. Scri,t:
..How to print numer o! users "o##ed in?
0.How to print status o! a"" processes? ,%hether runnin# or done-?
M.How do you print the status o! a #iven process #iven the process id?
&R:
..How was the technica" interview? AiHcu"t/Norma"/Easy/%orst?
0.Cou scored very "ess in written test/ why?
M.%hat is your current (T(? How much you are e8pectin#? (an you >usti!y?
P.How much time do you re+uire to >oin i! we #ive you oBer?
1. %hat is BTEQ?
2. %hat is e8p"ain in teradata?
3. %hat is 9ast"oad in Teradata?
4. %hat do you mean y s&ew ness?
5. How Inde8in# wor&s in Teradata?
6. %hat is Aataase Ae1nition ,ABA-?
7. %hat is stored procedure in Teradata?
8. %hat is Froup y in Se"ect statement?
9. %hat is asic teradata +uery "an#ua#e?
10. %hat is e8p"ainin# and how does it wor&?
11. %hat the de!au"t privi"e#es which #et assi#ned?
12. How does inde8in# improve +uery per!ormance?
13. %hat are two e8amp"es o! an '*T@ environment?
14. %hich two statements are true aout a !orei#n &ey?
15. %hat is the diBerence etween start schma and 9s"dm?
16. How many coddSs ru"es are satis1ed y teradata dataase?
17. How does Teradata avoid dup"icate rows in the SET Ta"es?
18. %hat is the new !eature that came a"on# with teradata W0)O?
19. %hat are the enhanced !eatures in Teradata W0)Q and W0)O?
20. Aoes SA*( chan#es when you use Teradata instead o! 'rac"e?
21. Aoes 9ast"oad support the use o! mustiest and dup"icates? %hy?
22. %hat is '*T@? How does teradata 1t into the dataase re+uirements?
23. %hat are the diBerent error ta"es used durin# a m"oad >o e8ecution?
24. E8p"ain the advanta#es and disadvanta#es o! a Hierarchica" Aataase?
25. %hat is the diBerence etween Wo"ati"e and F"oa" Temporary ta"es?
26. %hat is the diBerence etween the 9S*AJ and Star schema in
teradata?
27. %hat is a common data source !or the centra" enterprise data
warehouse?
28. %hich two can e imp"emented as a centra""y "ocated "o#ica"
architecture?
29. %hat is the diBerence etween Ju"ti"oad V 9ast"oad interms o!
@er!ormance?
30. %hat is the diBerence etween F"oa" temporary ta"es and Wo"ati"e
temporary ta"es?
31. In which sta#e o! Active Aata warehousin# do you have the
assessments over the !uture data?
32. How teradata ma&es sure that there are no dup"icate rows ein#
inserted when itSs a SET ta"e?
33. How wi"" you #o aout optimiUin# the per!ormance characteristics o!
the Teradata e8ecution?
34. %hat are the diBerent phases invo"vin# in "oadin# o! the data when it
comes to 9ast *oad and Ju"ti"oad?
35. In which phase o! the Active Aata %arehouse evo"ution do you use
data to determine what wi"" happen?
36. %hat is c"i+ues? %hat is Wdis& and how it wi"" communicate with
physica" data stora#e at the time o! data retrieva" throu#h AJ@?

You might also like