Teradata Teradata SQL 2 — Questions and Answers
Question 1: Which Teradata SQL command is used to remove all rows from a table without logging individual row deletions?
- DELETE ALL (Correct answer)
- TRUNCATE TABLE
- DROP TABLE
- REMOVE TABLE
Correct answer: DELETE ALL
DELETE ALL (or DELETE tablename ALL) removes all rows quickly; Teradata also supports TRUNCATE TABLE for similar fast deletion.
Question 2: What is the purpose of the WITH clause (Common Table Expression) in Teradata SQL?
- Defines a temporary named result set for use within the query (Correct answer)
- Locks a table for exclusive access
- Sets query priority
- Enables recursive joins
Correct answer: Defines a temporary named result set for use within the query
The WITH clause defines a Common Table Expression (CTE), which is a temporary named result set referenced within the same query.
Question 3: Which string function in Teradata returns the position of a substring within a string?
- INDEX (Correct answer)
- POSITION
- LOCATE
- FIND
Correct answer: INDEX
The INDEX function in Teradata returns the position of the first occurrence of a substring within a string.
Question 4: What does COALESCE return in Teradata SQL?
- The first non-NULL value from a list of expressions (Correct answer)
- The maximum of a set of values
- A concatenated string of all values
- The last non-NULL in a window
Correct answer: The first non-NULL value from a list of expressions
COALESCE evaluates each expression in order and returns the first non-NULL value found in the list.
Question 5: In Teradata, which keyword is used to sort query results in descending order?
- DESC (Correct answer)
- DESCENDING
- REVERSE
- DOWN
Correct answer: DESC
The DESC keyword in an ORDER BY clause sorts the result set from the highest to the lowest value.
Question 6: Which Teradata function formats a date value as a character string?
- TO_CHAR (Correct answer)
- FORMAT
- DATE_FORMAT
- CONVERT
Correct answer: TO_CHAR
TO_CHAR converts a date or numeric value to a character string using a specified format mask.
Which Teradata SQL command is used to remove all rows from a table without logging individual row deletions?