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
-
GRANT DML on DEPT to USER1;
-
GRANT select, update to USER1 on DEPT;
-
GRANT select, update on DEPT to USER1;
-
GRANT on DEPT to USER1 for select, update;
C
Correct answer
Explanation
The SQL statement to grant select, update privileges to the user RAKESH for the DEPT relation is
GRANT select, update on DEPT to USER1;
-
Cursor
-
Trigger
-
Select
-
Procedure
B
Correct answer
Explanation
A trigger is a statement which is executed automatically as an event after or before modification to the database.
-
Data Definition Language
-
Data Manipulation Language
-
Transaction Control Language
-
Object Oriented Language
-
Procedure Oriented Language
C
Correct answer
Explanation
In Oracle, commit and savepoint commands control the transactions specified in the form of queries. Hence, this is the correct option.
-
Grant and Commit
-
Savepoint and Revoke
-
Grant and Revoke
-
Commit and Rollback
D
Correct answer
Explanation
Transaction Control Language (TCL) commands in SQL manage transactions: COMMIT saves changes permanently, ROLLBACK undoes changes. GRANT and REVOKE are Data Control Language (DCL) commands for permissions. SAVEPOINT is a TCL command but paired with ROLLBACK TO, not GRANT/REvoke.
-
Revoke
-
Rollback
-
Savepoint
-
Commit
B
Correct answer
Explanation
ROLLBACK is the TCL command that undoes all changes made in the current transaction, restoring the database to its state before transaction began. COMMIT saves changes permanently. REVOKE is for permissions (DCL). SAVEPOINT marks a transaction point for partial rollback.
-
Delete
-
Remove
-
Truncate
-
Both (1) and (3)
D
Correct answer
Explanation
In SQL, DELETE removes specific rows based on a condition, while TRUNCATE removes all rows from a table quickly by de-allocating data pages. Both commands are used to remove rows - DELETE is more flexible for selective removal, while TRUNCATE is faster for complete table clearing. REMOVE is not a standard SQL command for this purpose.
-
Delete Table
-
Drop table
-
Erase Table
-
None of above
B
Correct answer
Explanation
DROP is the SQL command used to permanently remove database objects like tables and indexes. DELETE removes rows from a table but doesn't delete the table structure itself. DROP is part of Data Definition Language (DDL) operations.
-
Select distinct
-
Select unique
-
Select different
-
None of above
A
Correct answer
Explanation
SELECT DISTINCT is the SQL command that eliminates duplicate rows from query results, returning only unique values. DISTINCT is a keyword that filters out repeated rows in the specified columns. SELECT UNIQUE and SELECT DIFFERENT are not valid SQL syntax.
-
Select all from Table_Name
-
Select * Table_Name
-
Select full from Table_Name
-
Select full Table_Name
-
Select * from Table_Name
E
Correct answer
Explanation
Yes, it displays all the data that exist in the table.
-
Delete statement
-
Insert statement
-
Update statement
-
All the above
-
None of these
D
Correct answer
Explanation
Yes, Delete, Insert and Update change the data in the table.
-
a row
-
a text field
-
a record
-
a computed field
-
None of these
C
Correct answer
Explanation
In a customer database, a customer’s surname would be keyed into a record.
-
unlock the database
-
provide a map of the data
-
uniquely identify a record
-
establish constraints on database operations
-
none of these
C
Correct answer
Explanation
The primary key in a database table serves to uniquely identify each record/row. It ensures that no two records have the same value in the primary key column, enabling unambiguous identification and retrieval of specific records.
-
Schema, Base and Table
-
Base, Table and Schema
-
Key, Base and Table
-
Schema, Table and View
-
None of these
D
Correct answer
Explanation
SQL DDL (Data Definition Language) includes CREATE commands for Schema, Table, and View. These define the structure and relationships in a database. CREATE TABLE defines tables, CREATE VIEW defines virtual tables, and CREATE SCHEMA defines logical database groupings.
-
date + number
-
date - number
-
date - date
-
date + (number/24)
-
none of the above
C
Correct answer
Explanation
Difference between two dates returns a number. This output is different while others return only DATE.
-
There is a syntax error in the query.
-
It may return one row if the STUDENT_ID 119 is present in the table else it will return zero rows.
-
It always returns zero rows.
-
It returns n number of rows, where n is the number of students whose STUDENT_ID is 119.
-
It returns all the rows in the table irrespective of the data.