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
B
Correct answer
Explanation
External tables can accept data insertion in many database systems. For example, in Hive/Impala, you can insert data into external tables, though dropping the table won't delete the underlying data files. The statement claims data cannot be inserted, which is incorrect.
A
Correct answer
Explanation
External tables in most systems (including Netezza and Hive) do not support direct DELETE or TRUNCATE operations because they map to external files. You can't delete data from an external table without modifying the underlying file system directly.
-
Structured Question Language
-
Structured Query Language
-
Strong Question Language
-
None
B
Correct answer
Explanation
SQL stands for Structured Query Language, which is the standard language for relational database management systems. It is used for querying, manipulating, and defining data in databases.
-
SELECT
-
UPDATE
-
DELETE
-
ALTER
D
Correct answer
Explanation
DDL (Data Definition Language) statements define database structures. ALTER is a DDL command used to modify table structure. SELECT, UPDATE, and DELETE are DML (Data Manipulation Language) commands that operate on data within existing structures.
B
Correct answer
Explanation
SQL keywords are case-insensitive in most database systems. SELECT, Select, and select are all treated identically. However, string literals and identifier naming (depending on system) may be case-sensitive.
-
DROP
-
DELETE
-
TRUNCATE
-
All the Above
A
Correct answer
Explanation
The statement asks which SQL statement deletes a TABLE (not data). DROP TABLE completely removes the table structure and data from the database. DELETE removes rows but keeps the table, TRUNCATE removes all rows but keeps the table structure. Only DROP removes the table itself.
B
Correct answer
Explanation
The query uses LIKE '%la%' which matches any string containing 'la' anywhere (startswith, middle, or end). To match names starting with any character followed by 'la' (like 'Clara', 'Flavia'), the correct pattern would be '_la%' where underscore matches exactly one character. '%la%' matches 'Flamingo' (contains 'la'), not just patterns like '_la'.
-
SELECT LastName FROM Employee
-
EXTRACT LastName FROM Employee
-
SELECT Employee.LastName
-
None
A
Correct answer
Explanation
The SELECT statement is the standard SQL command for retrieving data from a database. The syntax 'SELECT column_name FROM table_name' correctly specifies which column to retrieve from which table. EXTRACT is not a valid SQL keyword for column retrieval, and 'SELECT Employee.LastName' would only work if using qualified notation with a table alias, which is not shown in the options.
-
SELECT *.Employee
-
SELECT [all] FROM Employee
-
SELECT * FROM Employee
-
SELECT Employee
C
Correct answer
Explanation
The asterisk () in SQL acts as a wildcard that represents all columns in a table. 'SELECT * FROM table_name' is the standard syntax to retrieve every column from the specified table. Options A and B use incorrect syntax ('.Employee' places the wildcard incorrectly, and '[all]' is not valid SQL syntax). Option D is missing both the column specification and FROM clause.
-
Update Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;
-
Update Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;
-
Update table Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;
-
Update table Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;
B
Correct answer
Explanation
The SQL UPDATE statement uses comma-separated assignments to update multiple columns, not the AND keyword. Option B correctly updates both salary (multiplied by 1.5) and grade (set to 'Promo') for rows where salary is less than 10000. Options A and D incorrectly use AND between column assignments, and option C unnecessarily includes the TABLE keyword which is not valid SQL syntax.
-
INSERT
-
DELETE
-
UPDATE
-
CREATE
D
Correct answer
Explanation
Data Definition Language (DDL) commands define database structures like tables, indexes, and schemas. CREATE is a DDL command used to create database objects. INSERT, DELETE, and UPDATE are Data Manipulation Language (DML) commands that manipulate data within existing structures.
-
PreparedStatement
-
ParameterizedStatement
-
ParameterizedStatement and CallableStatement
-
All kinds of Statements (i.e. which implement a sub interface of Statement)
A
Correct answer
Explanation
PreparedStatement is specifically designed to execute parameterized queries efficiently and safely. It pre-compiles SQL statements with placeholders (?) that are filled with parameter values at runtime, providing better performance and protection against SQL injection. Option B is fictional, and CallableStatement is for stored procedures.
-
CallableStatement
-
ParameterizedStatement
-
ParameterizedStatement and CallableStatement
-
All kinds of Statements (i.e. which implement a sub interface of Statement)
A
Correct answer
Explanation
CallableStatement executes stored procedures and functions that reside on the database server. It extends PreparedStatement and accepts parameters including OUT parameters for retrieving values from stored procedures. This allows executing complex logic encapsulated in database routines rather than embedding it in application code.
-
The executeUpdate method returns all the rows that were affected
-
The executeUpdate method returns the no. of rows that were affected
-
Depends , as there is more than one version of this method with different return types
-
NONE
B
Correct answer
Explanation
The executeUpdate() method returns an integer representing the number of rows affected by INSERT, UPDATE, or DELETE operations. This allows applications to verify whether the operation succeeded. Option A is imprecise (doesn't specify what's returned), and option C is incorrect; there's only one executeUpdate method signature that returns int.
B
Correct answer
Explanation
BDC (Batch Data Communication) tables in SAP follow specific naming conventions. The prefix 'T_BDC' is used for BDC-related tables. Other prefixes (T_, L_, W_) represent different table types (transparent, cluster, pooled) in the SAP system.