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

  2. False

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

SQL is a declarative language, not procedural. In SQL, you specify what data you want (declarative), not how to retrieve it (procedural). The database engine determines the optimal execution plan. Procedural languages like C or Java require step-by-step instructions including loops and conditional logic.

Multiple choice technology databases
  1. True

  2. False

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

Catch_#22 is a valid column name in SQL. While it looks unusual, SQL allows column names to contain underscores and numbers. The rules vary by database: some require quotes for special characters, but alphanumeric names with underscores are generally acceptable. The # character might require quoting in some databases, but the name itself is syntactically possible.

Multiple choice technology databases
  1. True

  2. False

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

In SQL query execution, WHERE clause filters individual rows BEFORE grouping, while HAVING clause filters groups AFTER aggregation. The logical order is: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY. WHERE cannot use aggregate functions, but HAVING can. This is why WHERE conditions are applied first to reduce the row set before grouping.

Multiple choice technology programming languages
  1. Provides code to execute if a key's own trigger fails

  2. Provides code to execute if user presses a key that has no trigger attached

  3. Provides code to execute if user presses wrong key

  4. Provides code that accesses another key's trigger and executes the code it contains

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

The KEY-OTHERS trigger in Oracle Forms defines the action to be taken when a user presses a function key that does not have its own specific key trigger defined, preventing default behavior or providing a fallback.

Multiple choice technology programming languages
  1. Never

  2. When data is committed

  3. Before the form is validated

  4. After the form is validated

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

When Validation Unit is Form, item-level validation (and thus PRE-TEXT-ITEM triggers) is bypassed. Validation occurs only at form level (e.g., on commit), so PRE-TEXT-ITEM never fires.

Multiple choice technology databases
  1. A table can have up to 10,000 columns.

  2. The size of a table does NOT need to be specified

  3. A table CANNOT be created while users are using the database

  4. The structure of a table CANNOT be modified while the table is online

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

When creating a table in a relational database, you do not need to specify its physical size, as storage is allocated dynamically. Tables can be created while users are active, and their structures can be modified online.

Multiple choice technology databases
  1. The statement will achieve the desired results

  2. The statement will execute, but will NOT enable the PRIMARY KEY constraint.

  3. The statement will execute, but will NOT verify that values in the ID column do NOT violate the constraint.

  4. The statement will return a syntax error.

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

The ALTER TABLE...ENABLE CONSTRAINT command re-enables a previously disabled constraint. This will successfully enable the PRIMARY KEY constraint inventory_id_pk and validate existing data, achieving the desired result.

Multiple choice technology databases
  1. The UNIQUE constraint does not permit a null value for the column.

  2. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.

  3. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index

  4. The NOT NULL constraint ensures that null values are not permitted for the column

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

PRIMARY KEY and UNIQUE constraints automatically create unique indexes to enforce uniqueness. NOT NULL explicitly prevents null values. UNIQUE constraints do permit null values (one per column in Oracle, multiple in standard SQL - though Oracle treats NULLs as not equal to each other), and FOREIGN KEY constraints create indexes for referential integrity checking but not unique indexes.

Multiple choice technology databases
  1. A MERGE statement is used to merge the data of one table with data from another.

  2. A MERGE statement replaces the data of one table with that of another.

  3. A MERGE statement can be used to insert new rows into a table.

  4. A MERGE statement can be used to update existing rows in a table.

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

MERGE combines insert and update operations in a single statement to synchronize tables. It inserts new rows when matches aren't found and updates existing rows when matches exist. MERGE does not replace entire table contents - it performs targeted operations based on match conditions between source and target.

Multiple choice technology databases
  1. CREATE TABLE EMP9$# AS (empid number(2));
  2. CREATE TABLE EMP*123 AS (empid number(2));

  3. CREATE TABLE PACKAGE AS (packid number(2));

  4. CREATE TABLE 1EMP_TEST AS (empid number(2));

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

Oracle table names must start with a letter, can contain letters, digits, and underscores, and cannot be a reserved word. Option A (EMP9$#) is valid because $ and # are allowed characters. Options B (*), C (PACKAGE is reserved), and D (starts with digit 1) are invalid.