Practice Question Answers and Explanations
- Correct answer: A
SQL language uses a set-oriented paradigm. Object-oriented and procedural paradigms are used for application-level programming languages. SQL is database-focused rather than application-focused. (Imperative logic is more application-focused.)
- Correct answer: D
The
SELECT
statement belongs to the Data Query Language (DQL) subset of SQL. Data Manipulation Language (DML) refers to SQL statements likeINSERT
andUPDATE
. Data Definition Language (DDL) refers to creating tables and so on. Data Control Language (DCL) refers to security. - Correct answer: A
True. Yes, delimited identifiers are treated as case-sensitive. Undelimited (without quotes) identifiers are treated as if they were written in uppercase.
- Correct answer: C
- Correct answer: B
A
GLOBAL TEMPORARY
table stores results for each session, but you do not have to recreate the table for every session. It is persisted. History column and virtual tables are not related to sessions. A local temporary table deletes the table after each session. - Correct answer: C
A semicolon (
;
) is used to terminate SQL statements. - Correct answer: A
A
SELECT *
statement is not recommended for use with column tables. Column tables are stored per column, andSELECT *
forces the database to read every column. It becomes much faster when it can ignore entire columns. - Correct answer: B
False. A
UNION ALL
statement returns all values in a result set, even duplicate records.UNION
only returns the unique records. - Correct answer: B
A colon (
:
) is prepended to a SQLScript variable when it is used as an input variable. - Correct answer: C
You can loop through records using imperative logic in SQLScript. It does NOT deliver the best possible performance. Declarative logic (the set-oriented paradigm) is much faster. The word only makes this statement “You can only use if-then logic” false, because we can also use loop logic with imperative logic.
- Correct answers: B, C
Dynamic SQL can be used for SQL injection, and you can dynamically change your data sources. The word always makes the “It is always bad for security” statement false. Dynamic SQL does NOT deliver the best possible performance.
- Correct answer: B
You create a scalar function when it has a return type of
BIGINT
. This returns a single value, and not a table-like result set. SQL functions and window functions are not user-defined functions. - Correct answers: A, D
- Correct answer: D
A user-defined function with the
INVOKER
security option checks the authorizations of the user calling the function when this function is executed. The_SYS_REPO
user is used if theDEFINER
security option is used. The owner of the function is no longer applicable once the function has been transported to the production system. TheSYSTEM
user is never used in this context. - Correct answer: C
You first have to know that the default security option for a procedure is the
DEFINER
security option.The
_SYS_REPO
user is used if theDEFINER
security option is used. The user calling the function is used for theINVOKER
security option. The developer of the procedure is no longer applicable once the function has been transported to the production system. - Correct answer: C
The preferred way to create a procedure is to create a .hdbprocedure file. All the other methods are deprecated! (This shows how much things have changed over the last few years.)
- Correct answers: C, D
You can call a table function with
SELECT
andEXEC
statements.EXEC
can be used to build a dynamic SQL statement that contains aSELECT
statement, for example. You CANNOT use a function toINSERT INTO
, because it’s read-only.CALL
is how procedures are called. - Correct answers: C, D
JOIN
is allowed in a user-defined function.COMMIT
,EXEC
, andINSERT
are not read-only statements. A UDF will not even activate when you have these in the function. - Correct answers: B, D
You need the
WITH RESULTS VIEW
andREADS SQL DATA
clauses to call a procedure in aSELECT
statement. - Correct answer: B
You have to run a
CREATE TYPE
statement before you can return table results from a procedure.CREATE TABLE TYPE
is deprecated. - Correct answers: C, D
GROUPING SETS
can return multiple result sets from a single SQL statement. All the other statements use multiple sources, but return a single result set. - Correct answers: C, D
Procedures can return multiple result sets. Table functions and views can only return single result sets. Scalar functions return (multiple) single values, not sets.
- Correct answer: A
UDFs can use imperative logic. They cannot commit transactions or use dynamic SQL (because they are read-only), and they cannot call procedures. (However, procedures can call UDFs.)
- Correct answers: A, D, E
Procedures can call views and table functions, and they may have input parameters. They may, but not must, return values. Because they can use dynamic SQL, they are open to SQL injection.
- Correct answer: C
We recommend using table functions rather than scripted calculation views.
- Correct answers: B, D
The migration tool workflow requires a script-based calculation view as input, and it produces a table function linked to a graphical calculation view. Graphical calculation views do not need to be migrated. It produces not only a table function, but also a graphical calculation view.