Computer Knowledge

Database and SQL

3,929 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 web technology
  1. You cannot use the WHERE clause to restrict groups.

  2. You cannot use the HAVING clause to restrict groups

  3. You cannot use group functions in the WHERE clause

  4. None of these

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

In SQL, group functions (like SUM or AVG) cannot be evaluated in the WHERE clause, and the WHERE clause itself cannot filter grouped results. The HAVING clause must be used instead, making both selected options correct descriptions of illegal queries.

Multiple choice technology web technology
  1. You cannot use the WHERE clause to restrict groups.

  2. You cannot use the HAVING clause to restrict groups

  3. You cannot use group functions in the WHERE clause

  4. None of these

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

When using group functions (aggregate functions like COUNT, SUM, AVG), you cannot use the WHERE clause to restrict groups: use HAVING for that. Also, group functions cannot appear in the WHERE clause because WHERE filters individual rows before grouping. Option B is incorrect because HAVING is specifically designed to restrict groups after aggregation.

Multiple choice technology databases
  1. 1

  2. 2

  3. 3

  4. 0

  5. 4

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

The query SELECT address1||','||address2||','||address2 creates only 1 column. The || operator concatenates strings, and the expression address1||','||address2||','||address2 concatenates these fields into a single column named 'Adress'. Even though multiple address fields are used, they are combined into one output column.

Multiple choice technology databases
  1. Primary key access

  2. Access via unique index

  3. Table access by ROWID

  4. Full table scan

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

ROWID is the physical address of a row in the database, representing its exact disk location. Accessing by ROWID is the fastest method because it bypasses all index lookups and goes directly to the data block. Primary key access and unique index access require first traversing the index structure to find the ROWID, then accessing the row. Full table scan is the slowest as it reads every row in the table.

Multiple choice technology databases
  1. Column

  2. 1966_Invoices

  3. Catch_#22

  4. #Invoices

  5. None of the above

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

In Oracle, standard unquoted identifiers must begin with a letter (A-Z) and can contain only letters, digits, and underscores. Option C is the only valid identifier that follows these rules. Option A uses a reserved word (though it would work if quoted). Option B starts with a digit which is invalid. Option D starts with # which is not allowed in unquoted identifiers. E is incorrect since C is valid.

Multiple choice technology databases
  1. select * from EMP where nvl(EMPNO, '00000') = '59384';

  2. select * from EMP where EMPNO = '59384';

  3. select EMPNO, LASTNAME from EMP where EMPNO = '59384';

  4. select 1 from EMP where EMPNO = '59834';

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

When a column is wrapped in a function like NVL(), the Oracle optimizer cannot use the index on that column because the function modifies the column value before comparison. For options B, C, and D, EMPNO is compared directly to a literal value, allowing index access. Option A applies NVL() to EMPNO first, making the index unusable and forcing a full table scan. This is a common performance anti-pattern.

Multiple choice technology databases
  1. 03-JUL-00

  2. 10-JUL-00

  3. 12-JUL-00

  4. 11-JUL-00

  5. 17-JUL-00

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

The NEXT_DAY function returns the first occurrence of a specified weekday that comes AFTER the current date. Since today is Monday, July 10, NEXT_DAY looks for the NEXT Monday, which is July 17. It doesn't return the current day, but the following instance of that weekday.

Multiple choice technology databases
  1. 8

  2. 2

  3. 3

  4. 4

  5. THERE IS NO SUCH CRITERIA

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

When joining n tables in Oracle (or most SQL databases), you need at least n-1 join conditions to avoid Cartesian products between the tables. For 4 tables, this means at least 3 join conditions. Each condition links one table to another, creating a chain that connects all tables.

Multiple choice technology programming languages
  1. 1

  2. 2

  3. 3

  4. 0

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

The SQL concatenation operator || joins multiple column values into a single result column. This query combines name, age, and address with comma separators, creating exactly one output column named 'emp_details'. The number of source columns concatenated doesn't affect the result column count.

Multiple choice technology programming languages
  1. Full table scan

  2. Table access by ROWID

  3. Access via unique index

  4. Primary key access

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

Accessing a row by its physical address (ROWID) is the fastest access path in Oracle. It allows Oracle to locate the row directly on disk in a single read. Other methods like index lookups or primary key access require searching the index structure first to find the ROWID.

Multiple choice technology programming languages
  1. DROP

  2. TRUNCATE

  3. DELETE

  4. CASCADE

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

The TRUNCATE command is a DDL statement that removes all rows from a table immediately. Because it is DDL, it commits automatically and does not write individual row deletes to the rollback segment, making it faster than DELETE. DROP deletes the table structure entirely.

Multiple choice technology databases
  1. Row level DML trigger

  2. Statement level DML trigger

  3. Row level Application trigger

  4. Statement level Application trigger

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

OLD and NEW qualifiers (referencing :OLD and :NEW values) are only available in row-level DML triggers. These qualifiers reference the before/after state of the row being modified. Statement-level triggers operate on sets of rows and don't have :OLD/:NEW context. Application triggers (Forms/Reports) have different mechanisms.