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
-
The value displayed in the CALC_VALUE column will be lower
-
The value displayed in the CALC_VALUE column will be higher
-
There will be no difference in the value displayed in the CALC_VALUE column
-
An error will be reported
C
Correct answer
Explanation
SQL operator precedence ensures multiplication always happens before addition, regardless of parentheses. The expression (.15*e.salary) + (.5*e.commission_pct) + (s.sales_amount * (.35*e.bonus)) evaluates identically without parentheses because all multiplication operations occur before any addition operations. The nesting of parentheses doesn't change this fundamental precedence rule. Options A and B are incorrect because the value remains the same. Option D is incorrect because no error occurs.
-
ON DELETE CASCADE
-
ON UPDATE CASCADE
-
CREATE SEQUENCE [SequenceName]
-
DROP SEQUENCE [SequenceName]
B
Correct answer
Explanation
Oracle SQL supports ON DELETE CASCADE for foreign key constraints, which automatically deletes child rows when the parent row is deleted. However, Oracle does not support ON UPDATE CASCADE - this is a MySQL-specific feature. If you need to update primary key values, you must manually update all dependent foreign key values or recreate the rows. Options A, C, and D are all supported Oracle SQL statements.
-
UNIQUE
-
SEQUENCE
-
AUTO_INCREMENT
-
None of the above -- Surrogate keys are not implemented in MySQL
C
Correct answer
Explanation
AUTO_INCREMENT is the MySQL property used to create surrogate keys. It automatically generates a unique numeric value for each new row, typically used for primary key columns. UNIQUE is a constraint that ensures column values are distinct but doesn't auto-generate values. MySQL doesn't use SEQUENCE objects like some other databases (Oracle, PostgreSQL).
-
UNIQUE
-
SEQUENCE
-
AUTO_INCREMENT
-
None of the above -- Surrogate keys are not implemented in MySQL
C
Correct answer
Explanation
AUTO_INCREMENT is the MySQL property used to create surrogate keys. It automatically generates a unique numeric value for each new row, typically used for primary key columns. UNIQUE is a constraint that ensures column values are distinct but doesn't auto-generate values. MySQL doesn't use SEQUENCE objects like some other databases (Oracle, PostgreSQL).
-
A cursor defines a private area in memory, when SQL statements are executed.
-
Implicit cursor are created, when any DML operation occurs in the database.
-
Explicit cursors are executed by default.
-
Explicit cursors can process only one record at a time.
-
None of the above
C
Correct answer
Explanation
Explicit cursors are not executed by default. They are executed when SELECT statement is used to return more than one row.
-
Triggers are executed automatically when any associated DML operation is executed.
-
In row level trigger, an even is fired when any row is updated.
-
Cyclic cascading in triggers can crash the database.
-
DESC USER_TRIGGERS function is used to get information about the trigger.
-
None of the above
-
Stored procedure reduces network traffic.
-
Stored procedures provide security to the database.
-
Stored procedure provides maintainability to the application.
-
Stored procedures are limited to T/SQL only and produce somewhat complexity.
-
(1), (2) and (3) all are true.
E
Correct answer
Explanation
Yes, all of these are the advantages of stored procedure.
-
A primary key cannot be NULL.
-
A foreign key can be NULL.
-
A foreign key can have the same name as primary key.
-
A foreign key can have the name other than the primary key.
-
None of the above
E
Correct answer
Explanation
This is the right choice as all the above statements are true.
-
A view in database provides security.
-
A view can hide the complexity of data in the database.
-
A view can act as aggregate tables.
-
A view can join multiple tables and simplify them as a single table.
-
All of the above are true statements.
E
Correct answer
Explanation
This is the correct choice as all of the above choices are correct.
-
Transitive dependency exists in the 3rd normal form of database.
-
1st normal form ensures that there should be a unique identifier for each row.
-
3rd normal form should be in 2nd normal form.
-
Normalisation is used to eliminate redundant data.
-
None of the above
A
Correct answer
Explanation
No, it is not true as 3rd normal form is used to remove the transitive dependency from the database tables.
-
Logical data independence
-
Physical data independence
-
Integrity independence
-
View updation rule
-
None of the above
A
Correct answer
Explanation
Yes, this is the rule given by E.F. Codd determines that the user view should not change despite the logical structures (splitting of tables) has been changed.
-
COUNT
-
SUM
-
AVG
-
MAX
-
None of the above
A
Correct answer
Explanation
Yes, this function is used to return the number of values from the column that matches the specified criteria.
-
Drop
-
Delete
-
Truncate
-
Both (1) and (3)
-
None of the above
A
Correct answer
Explanation
Yes, by using drop command we can remove an object from the database and if we want to drop a table then all the table structure will be removed form the database and we can not get back it.
-
Indexes are used to retrieve the rows of the database table quickly.
-
Indexes are not useful for the tables having less data.
-
The check constraints in SQL defines the business rules that should be follow by all the rows of the database.
-
Both (1) and (3) are true.
-
All (1), (2) and (3) are true.
E
Correct answer
Explanation
Yes, all the three statements are true.
-
Group By clause
-
Having clause
-
Distinct clause
-
Like clause
-
None of the above
B
Correct answer
Explanation
Yes, by using Having clause, we can make a condition on the data, which are retrieved by the Group By clause.