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

Multiple choice technology architecture
  1. Statement

  2. PreparedStatement

  3. ResultSet.

  4. Callable Statement

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

A PreparedStatement represents a precompiled SQL statement that is compiled once by the database management system and can be executed multiple times with different parameters. The standard Statement compiles SQL on every execution, while ResultSet holds query results and CallableStatement is for stored procedures.

Multiple choice technology
  1. True

  2. False

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

Accessing a materialized view requires explicitly querying the view by name in your SQL statement. You must write queries against the materialized view directly - the database does not automatically rewrite queries to use the materialized view instead of base tables. Query rewrite is an optional feature that must be explicitly enabled and configured.

Multiple choice technology
  1. Exit nzsql

  2. Shell escape or command

  3. Pause the current query

  4. None of the above

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

The ! meta-command in nzsql is used to pause the current query and escape to the shell to execute operating system commands. This allows users to run shell commands without exiting nzsql. To exit nzsql, use \q instead.

Multiple choice technology packaged enterprise solutions
  1. 1 Structure

  2. 2 Structures, both in the rows

  3. 2 Structures, one in rows and one in columns

  4. No Structures are required

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

Exception Cells in SAP BW queries require two structures: one in the rows and one in the columns. Exception cells are defined at the intersection of these structures. A single structure or no structures are insufficient - the intersection point is necessary for exception cell definition.

Multiple choice technology delivery
  1. Stored Procedures

  2. Temporary tables

  3. Views

  4. Triggers

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

In SQL Server, the COLLATE property at the database level affects permanent objects but has special behavior with temporary tables. Temporary tables are created in tempdb and inherit its collation, which can differ from the database collation. Stored procedures, views, and triggers can use collation settings within the database context.

Multiple choice technology databases
  1. Insert

  2. Create

  3. Delete

  4. Select

  5. Grant

  6. Commit

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

SELECT is the SQL statement used for data retrieval - it queries and returns data from database tables. Insert adds new data, Create defines structures, Delete removes data, Grant gives permissions, and Commit saves transactions - none of these are primarily for retrieval.

Multiple choice technology databases
  1. Insert

  2. Create

  3. Delete

  4. Select

  5. Merge

  6. Update

Reveal answer Fill a bubble to check yourself
A,C,E,F Correct answer
Explanation

Data Manipulation Language (DML) statements modify data: Insert adds new rows, Delete removes rows, Merge combines insert/update/delete operations, and Update modifies existing data. Create is DDL (defines structure), Select is for retrieval not manipulation.

Multiple choice technology databases
  1. Alter

  2. Rollback

  3. Select

  4. Commit

  5. Rename

  6. Savepoint

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

Transaction Control Language (TCL) commands manage transactions: Rollback undoes changes, Commit permanently saves changes, and Savepoint sets intermediate rollback points. Alter and Rename are DDL structure commands, Select is for retrieval.

Multiple choice technology databases
  1. Alter

  2. Grant

  3. Select

  4. Rename

  5. Revoke

  6. Update

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

Data Control Language (DCL) commands manage permissions and access: Grant gives privileges to users, Revoke removes privileges. Alter and Rename are DDL structure commands, Select retrieves data, Update modifies data - none are access control commands.

Multiple choice technology databases
  1. True

  2. False

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

A table in RDBMS follows the relational model's two-dimensional structure: rows (also called tuples or records) represent individual entries, and columns (attributes or fields) represent properties. This grid-like structure is fundamental to how relational databases organize and store data.

Multiple choice technology databases
  1. True

  2. False

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

In SQL SELECT statement syntax, ORDER BY is indeed the final clause. The standard order is: SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY. This makes sense logically because you must first determine which rows and columns you're working with before sorting them.

Multiple choice technology databases
  1. True

  2. False

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

The default sort order for ORDER BY in SQL is ascending (ASC), not descending. If you omit ASC/DESC, the database assumes you want ascending order. To sort in descending order, you must explicitly specify the DESC keyword.

Multiple choice technology databases
  1. True

  2. False

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

In SQL, the SELECT clause is processed before the ORDER BY clause in the logical query processing phase. Consequently, column aliases defined in the SELECT clause are visible and can be used to sort the result set in the ORDER BY clause.