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

Multiple choice technology programming languages
  1. 2

  2. 3

  3. 4

  4. 5

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. SELECT col1 INTO :hv from table1

  2. EXECUTE IMMEDIATE SELECT col1 INTO :hv FROM table1

  3. DECLARE c1 CURSOR FOR s1

  4. IMMEDIATE SELECT col1 INTO :hv FROM table1

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. two

  2. three

  3. four

  4. five

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. Omitting the ORDER BY clause when you create tables and views improve the query performance.

  2. using joins instead of subqueries improve the query performance.

  3. A good practice to improve query performance is using WHERE expressions to limit the size of result tables created with joins.

  4. Must use the ORDER BY clause when you create tables and views.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. 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.

  2. You cannot modify the descriptor portion of the data set using the MODIFY statement

  3. You can use the MODIFY statement to change the name of a variable.

  4. 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.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. SELECT

  2. FROM

  3. WHERE

  4. both a and c

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. user_constraints

  2. user_tables

  3. user_cons_columns

  4. all_tab_cols

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. By making use of the InsertStatement, DeleteStatement or UpdateStatement classes

  2. By invoking the execute(...) or executeUpdate(...) method of a normal Statement object

  3. By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...) methods of

  4. By making use of the execute(...) statement of the DataModificationStatement object

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. This means that the ResultSet is insensitive to scrolling

  2. This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not

  3. This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others

  4. The meaning depends on the type of data source, and the type and version of the driver you use with this data source

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. This means that the ResultSet is insensitive to scrolling

  2. This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not

  3. This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others

  4. The meaning depends on the type of data source, and the type and version of the driver you use with this data source

Reveal answer Fill a bubble to check yourself
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.