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
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.
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.
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.
B
Correct answer
Explanation
Pre-query trigger fires once before the query executes. Post-query trigger fires once per record fetched, so for 10 records it fires 10 times. This makes option B (1,10) correct.
-
Provides code to execute if a key's own trigger fails
-
Provides code to execute if user presses a key that has no trigger attached
-
Provides code to execute if user presses wrong key
-
Provides code that accesses another key's trigger and executes the code it contains
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.
-
DOWN
-
COMMIT_FORM
-
No Answer is Correct.
-
All Answers are Correct.
-
GO_ITEM
C
Correct answer
Explanation
PRE-UPDATE triggers have restricted built-in usage. DOWN is for navigation, COMMIT_FORM would cause recursion, and GO_ITEM is restricted in this context. These built-ins cannot be used in PRE-UPDATE triggers.
-
Never
-
When data is committed
-
Before the form is validated
-
After the form is validated
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.
-
A table can have up to 10,000 columns.
-
The size of a table does NOT need to be specified
-
A table CANNOT be created while users are using the database
-
The structure of a table CANNOT be modified while the table is online
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.
-
RAW
-
LONG
-
VARCHAR
-
LONG RAW
B,D
Correct answer
Explanation
In Oracle SQL, the ALTER TABLE...MODIFY command can convert legacy LONG and LONG RAW data types to modern LOB (Large OBject) types like CLOB and BLOB. This helps migrate older database schemas to use more flexible large object types.
-
The statement will achieve the desired results
-
The statement will execute, but will NOT enable the PRIMARY KEY constraint.
-
The statement will execute, but will NOT verify that values in the ID column do NOT violate the constraint.
-
The statement will return a syntax error.
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.
-
CONCAT
-
ROUND
-
TRUNC
-
RPAD
-
INSTR
A,D,E
Correct answer
Explanation
CONCAT concatenates strings, RPAD pads strings with specified characters to the right, and INSTR finds the position of a substring within a string. All three are character manipulation functions in SQL that work on text data.
-
The UNIQUE constraint does not permit a null value for the column.
-
A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
-
The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index
-
The NOT NULL constraint ensures that null values are not permitted for the column
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.
-
A MERGE statement is used to merge the data of one table with data from another.
-
A MERGE statement replaces the data of one table with that of another.
-
A MERGE statement can be used to insert new rows into a table.
-
A MERGE statement can be used to update existing rows in a table.
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.
-
CREATE TABLE EMP9$# AS (empid number(2));
-
CREATE TABLE EMP*123 AS (empid number(2));
-
CREATE TABLE PACKAGE AS (packid number(2));
-
CREATE TABLE 1EMP_TEST AS (empid number(2));
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.