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

  2. subtraction

  3. raising to a power

  4. finding the quotient

  5. finding the lowest value

Reveal answer Fill a bubble to check yourself
A,C,E Correct answer
Explanation

Oracle SQL supports arithmetic functions like ADD (addition), POWER (raising to a power), and MIN/LEAST (finding lowest value). Subtraction and division operations are typically done with operators (- and /) rather than built-in functions.

Multiple choice technology programming languages
  1. Subqueries can contain GROUP BY and ORDER BY clauses

  2. Main query and subquery can get data from different tables

  3. Main query and subquery must get data from the same tables

  4. Subqueries can contain ORDER BY but not the GROUP BY clause

  5. Only one column or expression can be compared between the main query and subqeury

  6. Multiple columns or expressions can be compared between the main query and subquery

Reveal answer Fill a bubble to check yourself
A,B,F Correct answer
Explanation

Subqueries can include GROUP BY and ORDER BY clauses, can access different tables than the main query, and support comparing multiple columns between main and subquery through multicolumn subqueries.

Multiple choice technology programming languages
  1. SELECT TO_CHAR('ll-oct-2007'. 'miDdspth "of Month. Year') FROM DUAL:

  2. SELECT TO_CHAR(TO_DATE('ll-oct-2007'X 'miDdspth of month, year') FROM DUAL;

  3. SELECT TO_CHAR(TO_DATE('ll-oct-2007'). 'miDdthsp "of* Month. Year') FROM DUAL;

  4. SELECT TO_DATE(TO_CHAR('ll-oct-20077fiiiDdspth "of" Month. Year')) FROM DUAL:

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology programming languages
  1. A subquery that defines a view cannot include the GROUP BY clause

  2. A view is created with the subquery having the DISTINCT keyword can be updated

  3. A view that is created with the subquery having the pseudo column ROWNUM keyword cannot be updated

  4. A Data Manipulation Language (DML) operation can be performed on a view that is created with the subquery having all the NOT NULL columns of a table

Reveal answer Fill a bubble to check yourself
C,D Correct answer
Explanation

Views using ROWNUM cannot be updated because the row numbers are generated dynamically, preventing direct row identification. Performing DML on a view with all NOT NULL columns from the base table is allowed because it satisfies the constraint integrity rules of the underlying table.

Multiple choice technology programming languages
  1. It ignores NULL values

  2. Reversing the order of the intersected tables alters the result.

  3. The names of columns in all SELECT statements must be identical.

  4. The number of columns and data types must be identical for all SELECT statements in the

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

INTERSECT returns rows common to both SELECT statements. It requires identical column counts and matching data types (D is true). Column names don't need to match (C is false). NULLs are treated like other values (A is false). INTERSECT is commutative (B is false).

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Triggers can enforce referential integrity by executing custom logic before or after INSERT/UPDATE/DELETE operations. They can validate data, prevent invalid operations, or cascade changes similar to foreign key constraints. While foreign keys are declarative and preferred, triggers offer programmatic control for complex scenarios.

Multiple choice technology databases
  1. Between -20000 and -20999

  2. Between -200000 and -209999

  3. Between -20001 and -20999

  4. Between -200001 and -209999

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

RAISE_APPLICATION_ERROR in Oracle allows user-defined error numbers from -20000 to -20999, giving developers 1000 error codes for custom exceptions. This range is reserved specifically for application-defined errors. Error numbers outside this range are reserved for Oracle system errors.

Multiple choice technology databases
  1. ALTER SESSION SET NEW_DATE_FORMAT = <date_format>

  2. ALTER SESSION SET CUR_DATE_FORMAT = <date_format>

  3. ALTER SESSION SET NLS_DATE_FORMAT = <date_format>

  4. ALTER SESSION SET SESS_DATE_FORMAT = <date_format>

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ALTER SESSION SET NLS_DATE_FORMAT changes the date format for the current session only. NLS (National Language Support) parameters control locale-specific formatting. The format string uses codes like 'DD-MON-YYYY' or 'MM/DD/YYYY'. This affects how dates are displayed and converted, not how they're stored.

Multiple choice technology databases
  1. 32767

  2. 1024

  3. 255

  4. 32765

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In PL/SQL, VARCHAR2 can hold up to 32767 bytes (32KB), which is much larger than the SQL limit of 4000 bytes. This extended capacity is useful for procedural code processing larger text strings. Options like 1024 or 255 are outdated limits from earlier versions or different contexts.

Multiple choice technology databases
  1. TO_CHAR, INOUT

  2. PROC, PACKAGE

  3. PRAGMA, MULTI_ROW

  4. SELECT, EXCEPTION

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

SELECT and EXCEPTION are both valid PL/SQL reserved words. SELECT is used for querying data, and EXCEPTION is used in exception handling blocks. The other options contain invalid words: INOUT is not a reserved word (it's a parameter mode), PROC is not reserved (PROCEDURE is), and MULTI_ROW is not a PL/SQL reserved term.

Multiple choice technology databases
  1. SET AUTOTRACE TRACEONLY

  2. SET AUTOTRACE ON

  3. SET AUTOTRACE ON STATISTICS

  4. SET AUTOTRACE ON EXPLAIN

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

SET AUTOTRACE ON displays both the execution plan (EXPLAIN) and statistics (STATISTICS) for SQL queries. The ON option combines both tracing capabilities. TRACEONLY suppresses query output, ON STATISTICS shows only statistics, and ON EXPLAIN shows only the execution plan - but ON gives you everything.

Multiple choice technology databases
  1. Comment marker

  2. Not equal to operator

  3. Label delimiter

  4. Greater than or equal to operator

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In PL/SQL, <> and >> are used to define label delimiters, which mark named blocks for use with GOTO statements or to label loops for nested loop control. The << marks the start of a label and >> marks the end. This is distinct from comment markers (-- or /* */) or comparison operators like >= or !=.

Multiple choice technology databases
  1. SQL%ROWCOUNT

  2. SQL%COUNT

  3. SQL%FOUND

  4. SQL%NUM_ROWS

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In PL/SQL, the implicit cursor attribute SQL%ROWCOUNT returns the exact number of rows affected by the last executed DML statement. SQL%FOUND returns a boolean, while SQL%COUNT and SQL%NUM_ROWS are not valid PL/SQL implicit cursor attributes.

Multiple choice technology databases
  1. The order of rows in a table is arbitrary

  2. A table can contain only one row formats

  3. The order of rows in a table is keyed to Primary Index.

  4. A table can contain multiple row formats

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

In relational databases, the order of rows in a table is arbitrary and not guaranteed - rows have no inherent positional order. Teradata tables can contain only one row format per table, which is a design constraint for performance and simplicity. Option C incorrectly ties row order to Primary Index, and option D is false because Teradata does not support multiple row formats in a single table.