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
-
Every entity must have a primary key
-
It is not necessary to define primary key for an Entity
-
@Primary annotation is used for denoting a simple primary key
-
All the above
A
Correct answer
Explanation
In JPA and entity frameworks, every entity MUST have a primary key to uniquely identify each instance. This is a fundamental requirement for entity mapping and database operations. Option B is incorrect because the primary key IS required. Option C is incorrect because @Primary is not a standard JPA annotation for simple primary keys (typically @Id is used). Option D is incorrect since not all statements are valid.
C
Correct answer
Explanation
In SQL*Plus, the hyphen character (-) is used as a continuation character when placed at the end of a line. It tells SQL*Plus that the SQL statement continues on the following line, allowing you to break long statements across multiple lines for readability.
-
Primary key access
-
Access via unique index
-
Table access by ROWID
-
Full table scan
C
Correct answer
Explanation
Access by ROWID is the fastest method because ROWID represents the direct physical address of a row in the database file. Once the ROWID is known, Oracle can go directly to that physical location without any index traversal, block searching, or table scanning.
B
Correct answer
Explanation
When joining N tables, you need at least N-1 join conditions to avoid Cartesian products. For 4 tables, this means 3 join conditions minimum. Each condition should properly link two tables, creating a connected join structure. With fewer conditions, some tables would remain unconnected, producing cross products.
-
Indexes are only used in special cases
-
Indexes are used to make table storage more efficient
-
Indexes rarely make a difference in SQL performance
-
Indexes exist solely to improve query speed
D
Correct answer
Explanation
Database indexes are separate data structures designed specifically to speed up data retrieval operations, making query execution faster at the cost of additional storage and write overhead.
-
SQL cannot support object-orientation
-
The same query can be written in many ways, each with vastly different execution plans.
-
SQL syntax is too difficult for non-computer professionals to use
-
SQL creates excessive locks within the database
B
Correct answer
Explanation
SQL is non-procedural and declarative, meaning the optimizer decides how to execute queries. A major challenge is that the same logical query can be written in multiple ways, yielding different execution plans and performance profiles.
A
Correct answer
Explanation
Index-Organized Tables (IOTs) in Oracle have specific partitioning restrictions. Interval partitioning, which automatically creates partitions based on a numeric or date range, cannot be applied to IOTs. IOTs support only certain partitioning methods like range or list partitioning, but the interval partitioning extension is not supported for them.
B
Correct answer
Explanation
Oracle 10g does not allow manual specification of trigger execution order. Triggers fire in a predetermined sequence: first statement-level triggers, then row-level triggers, and within those categories, the order is based on trigger creation time. The FOLLOWS clause for ordering triggers was introduced in Oracle 11g, not 10g.
-
Column
-
1966_Invoices
-
Catch_#22
-
#Invoices
C
Correct answer
Explanation
Oracle column names must start with a letter (A-Z or a-z) and can contain letters, numbers, and underscores. Option A 'Column' is a reserved keyword, Option B starts with a number, and Option D starts with '#'. Only Option C 'Catch_#22' is valid: it starts with a letter and the '#' symbol is allowed in non-leading positions.
-
FOR EACH ROW trigger on the EMP table
-
Statement-level Trigger on the EMP table
-
FOR EACH ROW trigger on the AUDIT_TABLE table
-
Statement-level Trigger on the AUDIT_TABLE
A
Correct answer
Explanation
To monitor every row change on a table, you need a row-level trigger using 'FOR EACH ROW' clause. This trigger fires once for each affected row during INSERT, UPDATE, or DELETE operations. A statement-level trigger fires only once per statement, regardless of how many rows are affected. The trigger must be on the source table (EMP), not the audit table.
-
Trigger type
-
Trigger body
-
Trigger event
-
Trigger Timing
A
Correct answer
Explanation
Trigger type determines execution frequency: row-level triggers fire once per affected row, while statement-level triggers fire once per DML statement regardless of rows affected. This is a fundamental distinction in database trigger behavior.
-
1
-
10
-
none
-
Value equal to number of rows in EMP table
A
Correct answer
Explanation
This is a statement-level trigger (no FOR EACH ROW clause). Statement-level triggers execute exactly once per triggering statement, regardless of how many rows are affected. Updating 10 rows still fires the trigger only once, inserting 1 row.
-
we can use Application Trigger to fire when a DELETE statement occurs
-
we can use database Trigger to fire when a INSERT statement occurs
-
we can use System event Trigger to fire when a DELETE statement occurs
-
we can use INSTEAD OF trigger to fire when a INSERT statement occurs
B
Correct answer
Explanation
Database triggers are stored programs that execute automatically in response to specific events on a table or view. Option A is incorrect because Application Trigger is not a standard database trigger type. Option B is correct - database triggers CAN fire when an INSERT statement occurs (among other DML operations). Option C is incorrect - system event triggers fire for DDL or database events, not DML DELETE. Option D is incorrect - INSTEAD OF triggers fire on views, not directly on INSERT statements to tables.
-
Package
-
Stored function
-
Stored procedure
-
Another DB trigger
C
Correct answer
Explanation
The CALL statement in Oracle triggers invokes stored procedures. It cannot call functions (which return values), packages (which are containers), or other triggers (to avoid recursive calls).