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

Multiple choice technology architecture
  1. Update Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;

  2. Update Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;

  3. Update table Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;

  4. Update table Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. INSERT

  2. CREATE

  3. UPDATE

  4. DELETE

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. PreparedStatement

  2. ParameterizedStatement

  3. ParameterizedStatement and CallableStatement

  4. All kinds of Statements (i.e. which implement a sub interface of Statement)

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. The executeUpdate method returns all the rows that were affected

  2. The executeUpdate method returns the no. of rows that were affected

  3. Depends , as there is more than one version of this method with different return types

  4. None

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Opening the administrator workbench

  2. Changing the query properties within the query designer

  3. Double-clicking on the characteristic in the query definition

  4. Creating a calculated key figure

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Structured Question Language

  2. Strong Question Language

  3. Structured Query Language

  4. Structured Query Limited

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice technology databases
  1. FETCH

  2. GET

  3. SELECT

  4. EXTRACT

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SELECT Persons.FirstName

  2. EXTRACT FirstName FROM Persons

  3. SELECT FirstName FROM Persons

  4. SELECT FROM FirstName IN Persons

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName='Peter'

  2. SELECT [all] FROM Persons WHERE FirstName='Peter'

  3. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

  4. SELECT * FROM Persons WHERE FirstName<>'Peter'

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName='%a%'

  2. SELECT * FROM Persons WHERE FirstName='a_'

  3. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

  4. SELECT * FROM Persons WHERE FirstName LIKE '%a'

Reveal answer Fill a bubble to check yourself
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.