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 databases
  1. SELECT &1, "&2"FROM &3 WHERE last_name = '&4';

  2. SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4'';

  3. SELECT &1, &2 FROM &3 WHERE last_name = '&4';

  4. SELECT &1, '&2' FROM EMP WHERE last_name = '&4';

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

In SQL*Plus, substitution variables are denoted by &n (like &1, &2, etc.) and allow user input at runtime. Option C correctly shows this syntax with &1, &2 for columns, &3 for table name, and &4 for the WHERE condition value. Option A incorrectly quotes &2. Option B has incorrect quoting and syntax errors. Option D hardcodes the table name as EMP instead of using a substitution variable.

Multiple choice technology databases
  1. Alice only

  2. Alice and Rena

  3. Alice, Rena, and Timber

  4. Sue, Alice, Rena, and Timber

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

Revoking a privilege from a user who granted it using WITH GRANT OPTION results in a cascading revoke. Since Sue revokes from Alice, Alice's grant to Rena, and Rena's subsequent grant to Timber are all cascades that get revoked.

Multiple choice technology programming languages
  1. A structure

  2. Client Independent

  3. Invalid

  4. Client Dependent

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

Tables without MANDT in the primary key are client-independent, meaning the data is shared across all clients in the SAP system. Client-dependent tables include MANDT as the first field of the primary key to isolate data by client. A structure is an ABAP dictionary object that doesn't store data physically, while client-dependent tables must include MANDT.

Multiple choice technology programming languages
  1. Adding technical settings to the table

  2. Checking the table syntax

  3. Saving the table

  4. Activating the table

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

Activating the table in the ABAP Dictionary compiles the metadata structure and physically creates the corresponding table in the underlying database. Saving only stores the definition locally, while syntax checking merely validates structural rules. Technical settings configure storage parameters but do not trigger database creation itself.

Multiple choice technology programming languages
  1. SE14

  2. SE15

  3. SE16

  4. SE16N

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

SE16N is the transaction code for the Table Browser (Data Browser) in SAP. It's an enhanced version of SE16 that provides faster access to table data with improved performance features. SE16N allows users to view, analyze, and export data from database tables without writing ABAP code.

Multiple choice technology programming languages
  1. Resultset

  2. Prepared Statement

  3. Statement

  4. Number of rows retrieved

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

The executeUpdate(String sql) method in JDBC returns an int representing the number of rows affected by the INSERT, UPDATE, or DELETE operation. It does NOT return ResultSet (use executeQuery() for that), PreparedStatement (that's what you call the method ON), or Statement objects.

Multiple choice technology programming languages
  1. 10 sec

  2. 5 sec

  3. 30 sec

  4. 0 sec

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

The SqlCommand object in ADO.NET has a default CommandTimeout of 30 seconds. This property controls how long the command waits for a response from the server before throwing a timeout exception. It can be modified via the CommandTimeout property if queries need more or less time. The 30-second default balances between allowing reasonable execution time for complex queries and preventing indefinite hangs.

Multiple choice technology databases
  1. You can use group functions in any clause of a select statement

  2. You can use group functions only in the column list of the SELECT statement by grouping on the single row columns

  3. You can pass column names, expressions, constants or functions as parameters to a group function

  4. You cannot group the rows of a table by more than one column while using group functions

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

Group functions, such as SUM or AVG, accept columns, expressions, constants, or other functions as arguments. They cannot be used in any clause (like the WHERE clause) and can group by multiple columns, making the other options incorrect descriptions of SQL group function behavior.

Multiple choice technology databases
  1. SELECT SUBSTR('Hello',) FROM dual;

  2. SELECT INITCAP(TRIM('Hello World',1,1)) FROM dual;

  3. SELECT LOWER(SUBSTR('Hello World',1,1)) FROM dual;

  4. SELECT LOWER(SUBSTR('Hello World',2,1)) FROM dual;

  5. SELECT LOWER(TRIM('H' FROM 'Hello World')) FROM dual;

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

The TRIM function with 'H' FROM removes the first character H, then LOWER converts to lowercase. Option E correctly removes 'H' from the beginning and converts the result to lowercase, yielding 'ello world'. Other options either use incorrect functions or wrong parameters.

Multiple choice technology databases
  1. Indexes are only used in special cases

  2. Indexes are used to make table storage more efficient

  3. Indexes rarely make a difference in SQL performance

  4. Indexes exist solely to improve query speed.

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

Indexes are database objects created specifically to accelerate data retrieval operations. They work like book indexes, allowing the database engine to locate rows quickly without scanning entire tables. While indexes do require additional storage and can slow down INSERT/UPDATE/DELETE operations, their primary and sole purpose is query performance optimization.

Multiple choice technology databases
  1. NOT NULL

  2. PRIMARY KEY

  3. FOREIGN KEY

  4. CHECK

  5. UNIQUE

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

Oracle automatically creates a unique index when you define a PRIMARY KEY or UNIQUE constraint to enforce uniqueness. This index supports quick lookups to check for duplicate values before insert/update operations. NOT NULL and CHECK constraints are validated through column value inspection, while FOREIGN KEY constraints are enforced through referential integrity checks - none of these require automatic indexes.