Computer Knowledge
Database and SQL
4,213 Questions
Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.
SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions
Database and SQL Questions
C
Correct answer
Explanation
Oracle databases use 4 main types of segments: data segments (table data), index segments (index data), undo segments (for rollback/undo), and temporary segments (for temporary operations). These are the core segment types in Oracle's storage architecture. Options A, B, and D don't represent the complete set.
-
SELECT col1 INTO :hv from table1
-
EXECUTE IMMEDIATE SELECT col1 INTO :hv FROM table1
-
DECLARE c1 CURSOR FOR s1
-
IMMEDIATE SELECT col1 INTO :hv FROM table1
B
Correct answer
Explanation
EXECUTE IMMEDIATE is the statement used to execute dynamic SQL statements that are constructed and executed at runtime. Option A uses static SQL with a host variable. Option C declares a cursor for a prepared statement. Option D has incorrect syntax.
A
Correct answer
Explanation
The PROC SQL step contains two statements: the PROC SQL statement and the SELECT statement. The SELECT clause, FROM clause, and ORDER BY clause are all part of the SELECT statement. The question asks for the number of statements, not clauses.
-
Omitting the ORDER BY clause when you create tables and views improve the query performance.
-
using joins instead of subqueries improve the query performance.
-
A good practice to improve query performance is using WHERE expressions to limit the size of result tables created with joins.
-
Must use the ORDER BY clause when you create tables and views.
D
Correct answer
Explanation
ORDER BY is an optional clause when creating tables and views, used only to sort the result set. Omitting it can improve performance by avoiding unnecessary sorting. WHERE clauses are recommended to limit result sizes. Using joins instead of subqueries is a performance best practice.
B
Correct answer
Explanation
The RESET statement in PROC SQL is used to reset specific options or settings, not to add, drop, or change options dynamically. It can reset certain parameters but does not provide the comprehensive option management described in the question.
-
MODIFY creates a second copy of the data while variables in the data are being matched with a WHERE clause and then deletes the second copy.
-
You cannot modify the descriptor portion of the data set using the MODIFY statement
-
You can use the MODIFY statement to change the name of a variable.
-
If the system terminates abnormally while a DATA step that is using the WHERE statement is processing, SAS automatically saves a copy of the unaltered data set.
B
Correct answer
Explanation
The MODIFY statement cannot modify descriptor information like variable names, labels, or attributes - only data values. Options A and C are false. Option D is incorrect as SAS does not automatically save copies during abnormal termination. Descriptor changes require other statements like RENAME.
-
SELECT
-
FROM
-
WHERE
-
both a and c
A
Correct answer
Explanation
The WHERE clause uses 'ge' which is a SAS operator, not a SQL operator. In PROC SQL, the correct operator is '>='. The SELECT and FROM clauses are written correctly with proper syntax for column selection and table reference.
B
Correct answer
Explanation
A table can have only one primary key constraint, though that primary key can consist of multiple columns (a composite key). The statement asks about multiple primary keys, which is not allowed in standard SQL - hence the answer is False.
A
Correct answer
Explanation
Unique constraints in SQL allow multiple NULL values because NULL represents unknown or missing data, not an actual value. The uniqueness check only applies to non-NULL values - each NULL is considered distinct from other NULLs. Therefore, you can insert as many NULL values as needed into a column with a unique constraint.
A
Correct answer
Explanation
SQL allows multiple CHECK constraints on a single column because each constraint is evaluated independently. For example, you could have one CHECK ensuring age >= 18 and another ensuring age <= 65 on the same column. All CHECK constraints must be satisfied for any INSERT or UPDATE operation on that column.
-
user_constraints
-
user_tables
-
user_cons_columns
-
all_tab_cols
A,C
Correct answer
Explanation
Oracle data dictionary views provide metadata about database objects. USER_CONSTRAINTS displays constraint definitions for the current user's tables. USER_CONS_COLUMNS shows which columns participate in which constraints. USER_TABLES and ALL_TAB_COLS contain table and column information but not constraint details.
-
By making use of the InsertStatement, DeleteStatement or UpdateStatement classes
-
By invoking the execute(...) or executeUpdate(...) method of a normal Statement object
-
By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...) methods of
-
By making use of the execute(...) statement of the DataModificationStatement object
B
Correct answer
Explanation
DML statements (INSERT, UPDATE, DELETE) are executed using Statement.execute() for general SQL or Statement.executeUpdate() which returns the row count. The other options describe non-existent classes and methods - there are no separate InsertStatement/DeleteStatement classes, nor executeInsert/executeDelete methods on Statement.
-
This means that the ResultSet is insensitive to scrolling
-
This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not
-
This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others
-
The meaning depends on the type of data source, and the type and version of the driver you use with this data source
C
Correct answer
Explanation
In JDBC, ResultSet.TYPE_SCROLL_INSENSITIVE indicates a scrollable result set that is not sensitive to changes made by others while it is open. Distractors confuse general scrolling ability with sensitivity to modifications.
-
This means that the ResultSet is insensitive to scrolling
-
This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not
-
This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others
-
The meaning depends on the type of data source, and the type and version of the driver you use with this data source
C
Correct answer
Explanation
TYPE_SCROLL_INSENSITIVE creates a scrollable ResultSet that allows bidirectional navigation (first, last, absolute, relative). The 'INSENSITIVE' means it doesn't reflect changes made by others after the ResultSet was created - it shows a static snapshot. Option A is wrong - 'insensitive' refers to change sensitivity, not scrolling ability. Option B has the sensitivity backwards.
D
Correct answer
Explanation
In PowerCenter Update Strategy, DD_INSERT has the numeric value 4. Other constants include DD_UPDATE (1), DD_DELETE (2), and DD_REJECT (3). The value 4 is used when flagging rows for insertion.