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 programming languages
  1. O (a) This means that the ResultSet is insensitive to scrolling

  2. O (b) This means that the Resultset is sensitive to scrolling, but insensitive to updates, i.e. not

  3. O (c) This means that the ResultSet is sensitive to scrolling, but insensitive to changes made

  4. O (d) The meaning depends on the type of data source, and the type and version of the driver

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ResultSet.TYPE_SCROLL_INSENSITIVE creates a scrollable ResultSet whose cursor can move both forward and backward (scrolling), but it does NOT reflect changes made to the underlying database data after the ResultSet was created (insensitive to updates). This provides a stable, static view of the data. In contrast, TYPE_SCROLL_SENSITIVE would show those changes.

Multiple choice technology programming languages
  1. O (a) Yes, but only if you call the method openCursor() on the ResultSet, and if the driver and

  2. O (b) Yes, but only if you indicate a concurrency strategy when executing the statement, and

  3. O (c) Yes, but only if the ResultSet is an object of class UpdateableResultSet, and if the driver

  4. O (d) No, ResultSets are never updateable. You must explicitly execute DML statements (i.e.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To answer this question, the user needs to have knowledge about ResultSets and their characteristics.

Option A is incorrect because there is no openCursor() method in the ResultSet class.

Option B is partially correct. The ResultSet object is updateable only if you indicate a concurrency strategy when executing the statement, and the driver supports updateable ResultSets.

Option C is incorrect because there is no class called UpdateableResultSet in the Java API.

Option D is incorrect because ResultSets can be updateable, but it depends on the driver, the type of ResultSet, and the concurrency strategy used.

Therefore, the correct answer is:

The Answer is: B

Multiple choice technology programming languages
  1. O (a) By asking a Transaction object to your Connection, and calling the method begin() on it

  2. O (b) By asking a Transaction object to your Connection, and setting the autoCommit property

  3. O (c) By calling the method beginTransaction() on the Connection object

  4. O (d) By setting the autoCommit property of the Connection to false, and execute a statement

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In JDBC, a transaction begins when you disable auto-commit by calling Connection.setAutoCommit(false). This shifts from single-statement auto-committing mode to manual transaction control. You then execute your SQL statements, and complete the transaction by calling commit() to apply changes or rollback() to cancel them. There is no beginTransaction() method in the JDBC Connection API.

Multiple choice technology programming languages
  1. [_] [a] Using the cursor technique is currently the only possible way to change the data in the

  2. [_] [b] Insert statements are not supported when using cursors.

  3. [_] [c] Only scrollable updateable ResultSets can use this approach to change the data in the

  4. [_] [d] The name of the cursor is specified by the setCursorName(String name) method the

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

In JDBC, positioned updates use a cursor name set via Statement.setCursorName(String). However, insert statements are not supported using the WHERE CURRENT OF cursor clause, making options b and d correct.

Multiple choice technology programming languages
  1. O (a) Call method execute() on a CallableStatement object

  2. O (b) Call method executeProcedure() on a Statement object

  3. O (c) Call method execute() on a StoredProcedure object

  4. O (d) Call method run() on a ProcedureCommand object

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct answer is A. You can execute a stored procedure in the database by calling the execute() method on a CallableStatement object.

Explanation:

A stored procedure is a precompiled set of SQL statements that are stored in the database. To execute a stored procedure, you need to create a CallableStatement object, which allows you to call the stored procedure.

Here's an example of how to execute a stored procedure using Java and JDBC:

// Assuming you have already established a database connection
CallableStatement cstmt = conn.prepareCall("{call your_stored_procedure(?, ?)}");

// Set any input parameters for the stored procedure, if needed
cstmt.setString(1, "input_parameter1");
cstmt.setInt(2, 2);

// Execute the stored procedure
cstmt.execute();

In the code above, your_stored_procedure is the name of the stored procedure you want to execute. The ? placeholders are used for any input parameters the stored procedure may require. You can set the input parameters using the setXxx() methods on the CallableStatement object.

Lastly, you call the execute() method on the CallableStatement object to execute the stored procedure.

Multiple choice technology programming languages
  1. [_] [a] To create a batch of insert and update statements, you create an object of type Batch,

  2. [_] [b] Batch insert and updates are only possible when making use of parameterized queries.

  3. [_] [c] To do a batched update/insert, you call addBatch(String statement) on a Statement

  4. [_] [d] To execute a batched update/insert, you call the executeBatch() method on a Statement

Reveal answer Fill a bubble to check yourself
C,D Correct answer
Explanation

In JDBC, batch updates are performed by adding SQL statements to a batch using Statement.addBatch(String sql) and then executing them together using Statement.executeBatch().

Multiple choice technology programming languages
  1. O (a) DDL statements are treated as normal sql statements, and are executed by calling the

  2. O (b) To execute DDL statements, you have to install additional support files

  3. O (c) DDL statements can not be executed by making use of JDBC, you should use the native

  4. O (d) Support for DDL statements will be a feature of a future release of JDBC

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To answer this question, the user needs to have knowledge about DDL (Data Definition Language) statements and their characteristics.

Now, let's go through each option and explain why it is right or wrong:

A. O (a) DDL statements are treated as normal SQL statements, and are executed by calling them. This statement is correct. DDL statements are used to define or modify the structure of database objects like tables, indexes, etc. and they are executed like normal SQL statements.

B. O (b) To execute DDL statements, you have to install additional support files. This statement is incorrect. There is no requirement for additional support files to execute DDL statements.

C. O (c) DDL statements cannot be executed by making use of JDBC, you should use the native database SQL interface. This statement is incorrect. DDL statements can be executed using JDBC (Java Database Connectivity) API like any other SQL statement.

D. O (d) Support for DDL statements will be a feature of a future release of JDBC. This statement is incorrect. DDL statements are already supported by JDBC.

Therefore, the correct option is:

The Answer is: A

Multiple choice technology databases
  1. Error

  2. All columns ordered randomly

  3. rows picked in a random way

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ORDER BY RAND() randomizes the sequence of rows returned by the query. Each execution returns rows in a different random order. Option C correctly describes this behavior. Option B is incorrect because it's the rows that are randomized, not individual columns.

Multiple choice technology operating systems
  1. Would skip the first 7, and then get you the next ten highest.

  2. not a valid mysql query

  3. Would skip the first 10, and then get you the next 7 highest.

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The LIMIT clause with two parameters works as LIMIT offset, count. LIMIT 7,10 means skip the first 7 rows, then return the next 10. Since ORDER BY column DESC sorts in descending order (highest first), skipping 7 and taking 10 gets rows 8-17 from the top. Option A correctly describes this behavior.

Multiple choice technology platforms and products
  1. SQl

  2. Query

  3. Case

  4. Validation

Reveal answer Fill a bubble to check yourself
C,D Correct answer
Explanation

Both Case statements and Validation components can be used to validate data in different contexts - Case transformation validates data conditionally, while Validation is a dedicated validation mechanism. SQL is for queries, Query is for data retrieval, not validation.

Multiple choice technology platforms and products
  1. Insert,Update,Delete,Normal

  2. Insert,Update,Normal

  3. Insert,Update,Delete

  4. Insert,Update,Delete,Reduce

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Table comparison transformation in ETL tools like Informatica produces four record types: Insert (new rows in target), Update (changed rows), Delete (rows removed from source), and Normal (unchanged rows that pass through). The Normal flag identifies rows that matched but had no changes, which is useful for auditing and tracking processing statistics.