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 databases
  1. Cursor

  2. Trigger

  3. Sequence

  4. View

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

PL/SQL packages can group related program units including procedures, functions, cursors, and variables. Option A (Cursor) is correct - cursors CAN be declared in a package specification. Triggers (B), Sequences (C), and Views (D) are standalone schema objects that CANNOT be part of packages.

Multiple choice technology databases
  1. Use a drop procedure statement to drop a standalone procedure.

  2. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification.

  3. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body.

  4. For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause.

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

DROP PROCEDURE removes standalone procedures. Packaged procedures cannot be dropped individually - you must drop or recreate the entire package body. Option A is correct. Options B and C are wrong because DROP PROCEDURE doesn't work on packaged procedures. Option D is nonsense - REUSE SETTINGS doesn't exist and ALTER PROCEDURE doesn't remove procedures.

Multiple choice technology databases
  1. If errors occur during the compilation of a trigger, the trigger is still created.

  2. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_TRIGGERS data dictionary view to see the compilation errors.

  3. If errors occur during the compilation of a trigger you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors.

  4. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors.

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

The question asks which statement is FALSE. Options A, C, and D are TRUE - triggers with compilation errors are still created (as INVALID), and you CAN view errors via SHOW ERRORS or USER_ERRORS. Option B claims you can use USER_TRIGGERS to see compilation errors, which is FALSE - compilation errors are in USER_ERRORS, not USER_TRIGGERS.

Multiple choice technology databases
  1. The rows are selected and ordered.

  2. The validity of the SQL statement is established.

  3. An area of memory is established to process the SQL statement.

  4. The SQL statement is run and the number of rows processed is returned.

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

In dynamic SQL processing, the execute phase runs the actual SQL statement and returns the count of affected rows. For INSERT/UPDATE/DELETE, this is when data modification happens and row counts are returned. Selecting/ordering rows (A) happens for queries. Validity checking (B) is parse phase. Memory allocation (C) is define/prepare phase.

Multiple choice technology databases
  1. Trigger type

  2. Trigger body

  3. Trigger event

  4. Trigger timing

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

Trigger TYPE determines execution frequency. Row-level triggers fire once per ROW affected. Statement-level triggers fire once per STATEMENT regardless of rows. Trigger body (B) is the code executed. Trigger event (C) is what fires it (INSERT/UPDATE/DELETE). Trigger timing (D) is before/after/in stead-of.

Multiple choice technology databases
  1. USER_PROCEDURES

  2. USER_PROCS

  3. USER_OBJECTS

  4. USER_PLSQL_UNITS

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

USER_OBJECTS is the standard dictionary view containing LAST_DDL_TIME, which shows when any schema object (including procedures) was last compiled or modified. USER_PROCEDURES and USER_PROCS are not standard Oracle views. USER_PLSQL_UNITS may exist in some versions but USER_OBJECTS is the canonical source for compilation timestamps.

Multiple choice technology mainframe
  1. LEFT JOIN

  2. RIGHT JOIN

  3. FULL JOIN

  4. SELF JOIN

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

All four options are valid JOIN types in SQL. LEFT JOIN returns all rows from left table plus matching right table rows. RIGHT JOIN returns all rows from right table plus matching left table rows. FULL JOIN returns all rows when there's a match in either table. SELF JOIN joins a table to itself. All are standard SQL JOIN types.

Multiple choice technology mainframe
  1. True

  2. False

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

The UNION operator in SQL combines the result sets of two or more SELECT statements and automatically removes duplicate rows, selecting only distinct values by default. To retain duplicates, UNION ALL must be used. Therefore, the statement is true.

Multiple choice technology mainframe
  1. Alternate Key

  2. Foreign Key

  3. Unique Key

  4. Alias Key

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

In relational database design, the primary key of a referenced table becomes a foreign key in the referencing table. The question is slightly ambiguous as the primary key itself is a primary key, but in the context of referencing, it acts as a foreign key. An alternate or alias key is incorrect.

Multiple choice technology programming languages
  1. True

  2. False

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

In database systems, index names must be unique within a schema or table to avoid conflicts. This allows the database to uniquely identify which index to maintain or query when referenced by name in DDL or DML statements.

Multiple choice technology databases
  1. purchase_date

  2. credit_card

  3. null

  4. credit_card & product_id

  5. product_id

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

Purchaser_Product is a junction table resolving a many-to-many relationship between Purchaser and Product. Its primary key must be the composite of both foreign keys (credit_card, product_id) to ensure each combination is unique and prevent duplicate purchaser-product associations. Neither credit_card nor product_id alone is sufficient.

Multiple choice technology databases
  1. COMMIT

  2. MERGE

  3. UPDATE

  4. DELETE

  5. CREATE

  6. DROP

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

DML (Data Manipulation Language) statements manipulate data: MERGE combines insert/update operations, UPDATE modifies existing rows, and DELETE removes rows. COMMIT is a transaction control statement (TCL). CREATE and DROP are DDL (Data Definition Language) statements that define schema structures, not manipulate data.