• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/71

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

71 Cards in this Set

  • Front
  • Back

T/F SQL functions are broadly divided into those that calculate and return a value for every row in a data set and those that return a single aggregated value for all rows.

True

What is a function?

A function is a program written to optionally accept input parameters, perform an operation, or return a single value.

T/F A function returns only one value per execution.

True

What three components for the basis of defining a function?

1. Input parameter list. It specifies zero or more arguments that may be passed to a function as input for processing.


2. Data type of its resultant value. Upon execution, only one value is returned by the function.


3. The third encapsulates the details of the processing performed by the function and contains the program code that optionally manipulates the input parameters, performs calculations and operations, and generates a return value.

A _______ is often described as a black box that takes an input, performs a calculation, and returns a value.

function

T/F Functions may be nested within other functions.

True

T/F Functions can only operate on certain data types.

False. They can operate on any available data types, the most popular being character, date, and numeric data. These operands may be columns or expressions.

Functions that operate on character data are broadly classified as case conversion and _____ _____ functions.

Character manipulation

_____, _____, and _____ are the case conversion functions that convert a given character column, literal, or expression into lowercase, uppercase, or initial case.

LOWER, UPPER, and INITCAP

The character manipulation functions include which 8 functions?

1. LENGTH


2. CONCAT


3. SUBSTR


4. INSTR


5. LPAD


6. RPAD


7. TRIM


8. REPLACE

What function uses a character string as an input parameter and returns a numeric value representing the number of characters present in that string?

LENGTH(string)

What does the CONCAT(string 1, string 2) function do?

It takes two strings and concatenates or joins them in the same way that the concatenation operator || does.



What does the SUBSTR function do?

It accepts three parameters and returns a string consisting of the number of characters extracted from the source string, beginning at the specified start position.

What is the syntax for the SUBSTR function?

SUBSTR(string, start position, number of characters)

What does the INSTR function do?

It returns a number that represents the position in the source string, beginning from the given start position, where the nth occurrence of the search item begins.

What do the LPAD and RPAD functions do?

THE LPAD and RPAD functions add a padding string of characters to the left or right of a string until it reaches the specified length after padding.

What does the TRIM function do?

The TRIM function literally trims off leading or trailing (or both) character strings from a given s

What does the REPLACE function do?

It locates the search item in a given string and replaces it with the replacement item, returning a string with replaced values.

What does the ROUND function do?

It facilitates rounding off a number to the lowest or highest value given a decimal precision format.

What does the TRUNC function do?

It drops off or truncates the number given a decimal precision value.

What does the MOD function do?

It returns the remainder of a division operation

What does the MONTHS_BETWEEN function do?

It returns the number of months between two dates.

What does the ADD_MONTHS function do?

It returns the date resulting from adding a specified number of months to a date.

What does the LAST_DAY function do?

It returns the last day of the month that the specified date falls into

What does the NEXT_DAY function do?

It returns the date on which the next specified day of the week falls after the given date.

What does the SYSDATE function do?

It takes no parameters and returns a date value that represents the current server date and time.

T/F If a query selects 10 rows, the function is executed 10 times, once per row with the values from that row as input to the function.

True

What are multiple-row functions?

Functions that operate on more than one at a time.

What are some typical uses of multiple-row functions?

- Calculating the sum or average of the numeric column values.


- counting the total number of records in sets.

The character case conversion functions serve two important purposes. What are they?

1. To modify the appearance of a character data item for display purposes


2. to render them consistent for comparison operations.

What does the LOWER function do?

- converts a string of characters into their lowercase.


- Does not add extra characters or shorten length.


- Uppercase characters are converted into their lowercase equivalents. Numeric, punctuation, or special characters are ignored.

The LOWER function can take only ____ parameter(s).

one

What is the syntax for the LOWER function?

LOWER(s).

What does the following query return?




select lower (100) from dual

100

What does the following query return?




select lower ('The SUM'||'100+100'||'=200') from dual

"The sum 100 + 100 = 200

What does the UPPER function do?

- converts a string of characters into their uppercase equivalents.


- It does not add extra characters or shorten the length of the initial string.


- All lowercase characters are converted into their uppercase equivalents.


- Numeric, punctuation, or special characters are ignored.

T/F The UPPER function only take one parameter

True.

What is the syntax for the UPPER function?

UPPER(s)

What does the INITCAP function do?

- It converts a string of characters into capitalized case.


- It is often used for data presentation purposes.


- The first letters of each word in the string are converted to their uppercase equivalents, while the remaining letters of each word are converted to their lowercase equivalents.

T/F The INITCAP function can take more than one parameter.

False. It can only take one.

What is the syntax for INITCAP function?

INITCAP(s)

Assuming SYSDATE is 17-DEC-07, what would the following query return?




select initcap (SYSDATE) from dual

17-Dec-07

What function joins two character literals, columns or expressions to yield one larger character expression?

The CONCAT function

How many parameters does the CONCAT function take?

Two

What is the syntax for the CONCAT function?

CONCAT(s1, s2) where s1 and s2 represent string literals, character column values, or expressions resulting in character values.

What is the result of the following query:




select concat (1+2.14, 'approximates pi') from dual

3.14 approximates pi

What does the LENGTH function do?

It returns the number of characters that constitute a character string. This includes character literals, columns, or expressions. Numeric and date literals are automatically cast as characters when they occur as parameters to the LENGTH function.

T/F Blank spaces, tabs, and special characters are not counted by the LENGTH function.

False. They are all counted by LENGTH function.

How many parameters does the LENGTH function take?

only one

What is the syntax for the LENGTH function?

LENGTH(s)

What is the result from the following query:




select length(1+2.14 ||'approximates pi') from dual

- 20


- The numeric expression is evaluated to return the number 3.14. This number is cast as the character string "3.14" which is then concatenated to the character literal "approximates pi". The resultant character string contains 20 characters.

What is the result of the following query is the SYSDATE is 17-DEC-07?




select length (SYSDATE) from dual

- 9


- The query first evaluates SYSDATE function, which returns the current system date.


- This value is automatically converted to a character string whose length is then determined.

What do the LPAD and RPAD functions do?

They return a string padded with a specified number of characters to the left or right of the source string.




- Numeric and date literals are implicitly cast as characters when they occur as parameters to the LPAD and RPAD functions.

How many parameters do the LPAD and RPAD functions take?

Three

What is the syntax for LPAD and RPAD?

LPAD(s,n,p) and RPAD(s,n,p)




- s represents the source string


- n represents the final length of the string returned


- p specifies the character string to be used as padding.

If LPAD is used, the padding characters ___ are added to the left of the ______ _____ s until it reaches length ____.

p, source string, n.

If RPAD is used, the padding characters p are added to the ______ of the source string s until it reaches length n.

right

T/F If the parameter n is smaller than or equal to the length of the source string s, then no padding occurs and only the first n characters of s are returned.

True.

What are the results of the following query?




select lpad (1000+200.55, 14, '*') from dual

*******1200.55

What are the results of the following query?




select rpad (1000+200.55, 14, '*') from dual

1200.55*******

What are the results of the following query if SYSDATE is 17-DEC-07?




select lpad(SYSDATE, 14, '$#') from dual

$#$#$17-DEC-07




- The date is converted into a string, and the padding string is systematically applied to reach the target length.

What is the result of the following query if SYSDATE is 17-DEC-07?




select rpad(SYSDATE, 4, '$#') from dual

17-D




- The RPAD function in the query has a target length of 4 characters, but the SYSDATE function alone returns a 9 character value. Therefore no padding occurs and the first four characters of the date are returned.

What does the TRIM function do?

It removes characters from the beginning or end of character literals, columns or expressions to yield one potentially shorter character item.

T/F Numeric and data literals are automatically cast as characters when they occur as parameters to the TRIM function.

True.

T/F Numeric or date expressions are evaluated last after being converted to strings ready to be trimmed.

False. They are evaluated first before being converted to strings ready to be trimmed.

The TRIM function takes a parameter made up of an _____ and a _____ component

optional, mandatory

What is the syntax for the TRIM function?

TRIM([trailing|leading|both] trimstring from s)




- The string to be trimmed (s) is mandatory.

T/F TRIM(s) removes spaces from both sides of the input string.

True.

What does TRIM(trailing trimstring from s) do?

It removes all occurrences of trimstring from the end of the string s if it is present.

What does TRIM(leading trimstring from s) do?

It removes all occurrences of trimstring from the beginning of the string s if it is present.

What does TRIM(both trimstring from s) do?

It removes all occurrences of trimstring from the beginning and end of the string s if it is present.