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
-
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
In SQL UPDATE statements, multiple column assignments must be separated by commas, not the AND keyword. The correct syntax is 'UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition'. Option A incorrectly uses 'and' instead of a comma. Options C and D incorrectly include 'table' keyword after UPDATE.
-
INSERT
-
CREATE
-
UPDATE
-
DELETE
B
Correct answer
Explanation
Data Definition Language (DDL) commands define or modify database structures like tables, indexes, and schemas. CREATE is a DDL command used to create database objects. INSERT, UPDATE, and DELETE are Data Manipulation Language (DML) commands that manipulate the data within those 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 safely and efficiently. It precompiles the SQL statement with placeholders (?) and allows setting parameters separately, preventing SQL injection. Regular Statement doesn't support parameterized queries. CallableStatement is for stored procedures.
-
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 in JDBC returns an integer representing the number of rows affected by the SQL operation (INSERT, UPDATE, DELETE). It doesn't return the actual row data - just a count. For SELECT queries, you'd use executeQuery which returns a ResultSet.
B
Correct answer
Explanation
Characteristic variables CAN be created directly from the Query Designer tool in SAP BW. The statement claims they cannot be created, which is false. Therefore, the correct answer is 'False' (option B), indicating that the statement in option A is incorrect.
-
Opening the administrator workbench
-
Changing the query properties within the query designer
-
Double-clicking on the characteristic in the query definition
-
Creating a calculated key figure
C
Correct answer
Explanation
Double-clicking on a characteristic in the query definition opens the restriction dialog where you can specify values, ranges, or variables to limit the characteristic. Option A (administrator workbench) is a general tool, not a specific action. Option B (changing query properties) affects the query globally, not individual characteristics. Option D (calculated key figure) creates a new key figure rather than restricting an existing characteristic.
-
Structured Question Language
-
Strong Question Language
-
Structured Query Language
-
Structured Query Limited
C
Correct answer
Explanation
SQL stands for Structured Query Language, a standard language designed for managing database records and executing queries. The other options are incorrect variations using words like 'Question', 'Strong', or 'Limited' instead of the standard 'Query' and 'Language'.
C
Correct answer
Explanation
SELECT is the SQL statement used to retrieve/extract data from database tables. It's the most fundamental SQL query operation. FETCH is used in cursors (not a standalone data retrieval statement), GET and EXTRACT are not standard SQL keywords for retrieving data from tables.
-
UPDATE
-
MODIFY
-
SAVE AS
-
SAVE
A
Correct answer
Explanation
UPDATE is the correct SQL statement for modifying existing data in database tables. You use UPDATE with SET to change column values. MODIFY, SAVE AS, and SAVE are not standard SQL statements for updating table data.
-
REMOVE
-
COLLAPSE
-
DELETE
-
REMOVE ALL
C
Correct answer
Explanation
DELETE is the SQL statement used to remove rows from database tables. You can delete specific rows using a WHERE clause or all rows (without WHERE). REMOVE, COLLAPSE, and 'REMOVE ALL' are not valid SQL keywords for deleting data.
-
ADD NEW
-
ADD RECORD
-
INSERT NEW
-
INSERT INTO
D
Correct answer
Explanation
INSERT INTO is the standard SQL command for adding new records to a table. The syntax requires specifying the table name after the keywords, making INSERT INTO the only valid option among the choices.
-
SELECT Persons.FirstName
-
EXTRACT FirstName FROM Persons
-
SELECT FirstName FROM Persons
-
SELECT FROM FirstName IN Persons
C
Correct answer
Explanation
Selecting a column requires the SELECT columnName FROM tableName syntax. Therefore, SELECT FirstName FROM Persons is correct. SELECT Persons.FirstName lacks the mandatory FROM clause, EXTRACT is not the correct command, and the IN syntax is invalid for basic column retrieval.
-
SELECT *.Persons
-
SELECT Persons
-
SELECT * FROM Persons
-
SELECT [all] FROM Persons
C
Correct answer
Explanation
The correct syntax is SELECT * FROM table_name, where * means 'all columns' and FROM specifies the table. SELECT *.Persons and SELECT Persons are invalid - SQL requires the FROM keyword to separate columns from the table name.
-
SELECT * FROM Persons WHERE FirstName='Peter'
-
SELECT [all] FROM Persons WHERE FirstName='Peter'
-
SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
-
SELECT * FROM Persons WHERE FirstName<>'Peter'
A
Correct answer
Explanation
The standard SQL query to retrieve exact matches uses the '=' operator. SELECT * retrieves all columns from the table. The keyword [all] is not standard SQL syntax for selecting columns, and '<>' signifies 'not equal to'.
-
SELECT * FROM Persons WHERE FirstName='%a%'
-
SELECT * FROM Persons WHERE FirstName='a_'
-
SELECT * FROM Persons WHERE FirstName LIKE 'a%'
-
SELECT * FROM Persons WHERE FirstName LIKE '%a'
C
Correct answer
Explanation
In SQL, the LIKE operator combined with the '%' wildcard matches any sequence of characters. 'a%' matches any string starting with 'a'. Using '=' searches for exact literal matches, and '_' only matches a single character.