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 databases
  1. TRUE

  2. FALSE

  3. BOTH

  4. NONE

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

This is false - FETCH with a cursor does NOT require explicit direction. If you omit NEXT/PRIOR/FIRST/LAST/ABSOLUTE/RELATIVE, the default is NEXT, which fetches the next row sequentially. The statement can use implicit direction, making the 'always' in the question incorrect.

Multiple choice technology programming languages
  1. True

  2. False

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

A PreparedStatement is indeed precompiled - the SQL statement template is parsed, compiled, and optimized when the statement is created (often on the connection), not when it's executed. This allows efficient reuse with different parameter values and provides some performance benefits for repeated executions.

Multiple choice technology web technology
  1. Data Reader

  2. Data Table

  3. Dataset

  4. Data Row

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

ADO.NET's fundamental objects are DataReader (connected, forward-only read) and Dataset (disconnected, in-memory cache). DataAdapter and DataRelation are supporting objects, while DataTable and DataRow are Dataset contents.

Multiple choice technology databases
  1. CASCADE

  2. UNIQUE

  3. NONUNIQUE

  4. CHECK

  5. PRIMARY KEY

  6. NOT NULL

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

Oracle constraints are: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK, and (for deferred constraints) initially deferred/deferred. CASCADE is a referential action (ON DELETE CASCADE), not a constraint type. NONUNIQUE is not a constraint.

Multiple choice technology databases
  1. INSERT

  2. UPDATE

  3. SELECT

  4. DESCRIBE

  5. DELETE

  6. RENAME

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

The DESCRIBE command is a command-line utility command in SQL*Plus and iSQL*Plus used to display the structure of a table. SELECT, INSERT, UPDATE, and DELETE are standard SQL Data Manipulation Language (DML) statements, not client-specific commands.

Multiple choice technology databases
  1. the use of rowed

  2. a GROUP BY clause

  3. an ORDER BY clause

  4. only an inline view

  5. an inline view and an outer query

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

Top-N queries need sorted data (ORDER BY) and a way to limit results - typically using an inline view with ROWNUM (Oracle) or LIMIT/FETCH (other databases) plus an outer query. Inline views are standard; GROUP BY is for aggregation.

Multiple choice technology databases
  1. creates a view with constraints

  2. creates a view even if the underlying parent table has constraints

  3. creates a view in another schema even if you don't have privileges

  4. creates a view regardless of whether or not the base tables exist

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

The FORCE option in SQL view creation allows creating a view even when the base tables don't exist yet. This is useful for defining view structures before the underlying data is available. Without FORCE, the view creation would fail if base tables are missing.

Multiple choice technology databases
  1. GRANT select ON dept TO ALL USERS;

  2. GRANT select ON dept TO ALL;

  3. GRANT QUERY ON dept TO ALL USERS;

  4. GRANT select ON dept TO PUBLIC;

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

To solve this question, the user needs to know the SQL syntax for granting privileges to users and the difference between "ALL USERS" and "PUBLIC".

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

A. GRANT select ON dept TO ALL USERS; This option is incorrect because the correct keyword to grant privileges to all users is "PUBLIC" instead of "ALL USERS". Also, "QUERY" is not a valid keyword, and the correct keyword to grant query privileges is "SELECT". Therefore, option A is incorrect.

B. GRANT select ON dept TO ALL; This option is incorrect because the correct keyword to grant query privileges is "SELECT" instead of "QUERY". Also, "ALL" is not a valid keyword to grant privileges to all users, and the correct keyword is "PUBLIC". Therefore, option B is incorrect.

C. GRANT QUERY ON dept TO ALL USERS; This option is incorrect because "QUERY" is not a valid keyword to grant privileges, and the correct keyword is "SELECT". Also, "ALL USERS" is not a valid keyword to grant privileges to all users, and the correct keyword is "PUBLIC". Therefore, option C is incorrect.

D. GRANT select ON dept TO PUBLIC; This option is correct. The correct keyword to grant select (query) privileges is "SELECT". The keyword "PUBLIC" is used to grant privileges to all users. Therefore, option D is the correct answer.

The Answer is: D

Multiple choice technology databases
  1. A MERGE statement is used to merge the data of one table with data from another

  2. A MERGE statement replaces the data of one table with that of another

  3. A MERGE statement can be used to insert new rows into a table

  4. A MERGE statement can be used to update existing rows in a table

Reveal answer Fill a bubble to check yourself
A,B,C Correct answer