In order to compare an attribute with string,it is required to surround the string by apostrophes ,e.g where LOCATION=’DALLAS’.A powerful operator for pattern matching is the like operator . Together with this operator ,two special characters are used ;the percent sign % (also called wild card),and the underline _,also called position marker e.gif one is interested in all tuples of the table DEPT that contain two C in the name of the department ,the condition would be where DNAME like “%C%C%”.the % sign means that any (sub)string is allowed there ,even the empty string .in contrast ,the underline stands for exactly one character .Thus the condition where DNAMElike “%C_C%” would require that exactly one character appears between the two Cs .To test for inequality ,the not clause is used.
Further string operation are :
1.upper
2.lower
3.initcap
4.length
5.substr




No comments:
Post a Comment