chapter 4 Flashcards
what does the DUAL table contain
Has one row called “X” and one column called “DUMMY”
how many rows will queries using the dual table return
return 1 row
what is the dual table used for ?
used to create SELECT statements and execute functions not directly related to a specific database table
what are the 2 categories that single row functions are divided into ?
–> functions that convert the case of character strings
–> functions that can join, extract, show, find, pad, and trim character strings
name 3 clauses where single row functions can be used
select, where, order by
what does case manipulation allow you to do ?
You may not always know in which case (upper, lower, mixed) the data is stored in the database. Case manipulation allow you to temporarily cover the database data to a case of your choosing
advantage of performing case manipulation
mismatches between database case storage and query case requests are avoided as you can format the output and search for specific strings
name 7 character manipulation functions
concat
substr
length
instr
LPAD/RPAD
Trim
replace
true or false
case manipulation functions can be used in most parts of the queries
true
which function converts alpha characters to lower-case
LOWER(column)
which function converts alpha characters to upper-case
UPPER(column)
which function converts alpha characters values to uppercase for the first letter of each word
INITCAP(column)
what are character manipulation functions used for
they are used to extract, change, format, or alter in some way a character string
what does the character manipulation function take in as input and give out as output
inputs: one or more characters or words
output: changed, extracted, counted or altered value
how many values does the concat function join
2
what is the output for
SELECT CONCAT(‘HELLO’, ‘WORLD’)
FROM DUAL;
HELLOWORLD (there is no space similar to the double pipe operator used for concatenation)
what does the SUBSTR function return
Extracts a string of a determined length
for example
SELECT SUBSTR(‘HelloWorld’, 1, 5)
FROM DUAL
will return a sub string that starts from 1st character and is 5 characters in length
which argument is optional in sql substr function
length argument. If omitted, returns all the characters to the end of the string
what does the length function in sql do
shows the length of a string as a number value
what does the length function take in as argument
takes a character string as an argument and returns the number of characters in the string
what does the INSTR function do
searches for the first occurrence of a substring within a character string and returns the position as a number
what happens if no substring is found
0 is returned
what does LPAD do
pads the left side of a character string, resulting in a right justified value
how many arguments does LPAD require
takes in a character string, total number of characters in the padded string, which character to pad with