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. IN executes the inner query for each row affected by the outer query and EXISTS executes the inner query only once irrespective of the outer query

  2. IN executes the inner query only once irrespective of the outer query and EXISTS executes the inner query only once irrespective of the outer query

  3. IN executes the inner query only once irrespective of the outer query and EXISTS executes the outer query for each row affected by the outer query

  4. IN executes the inner query for each row affected by the outer query and EXISTS executes the outer query for each row affected by the outer query

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

The IN operator evaluates the subquery once to get a list of values, whereas EXISTS evaluates the subquery for each row processed by the outer query to check for the existence of a match.

Multiple choice technology databases
  1. Defined immediately after the table CREATE statement, used to find the Primary Key

  2. Defined during the table CREATE statement, used to assign rows to an AMP

  3. Defined immediately after the table CREATE statement, used to assign rows to an AMP

  4. Defined during the table CREATE statement, used to find the Primary Key

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

The Primary Index is defined within the CREATE TABLE statement (not after). Its core purpose is to distribute rows to AMPs via the hashing algorithm. It is not used to find the Primary Key - PK is for uniqueness and relationships.

Multiple choice technology databases
  1. Defined immediately after the table CREATE statement, used to assign rows to an AMP

  2. Defined immediately after the table CREATE statement, used to find the Primary Key

  3. Defined during the table CREATE statement, used to assign rows to an AMP

  4. Defined during the table CREATE statement, used to find the Primary Key

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

In Teradata, the Primary Index (PI) is defined during the table CREATE statement. It is used by the hashing algorithm to assign and distribute table rows across Access Module Processors (AMPs).

Multiple choice technology databases
  1. select '''||'TCS'||''' from dual

  2. select 'TCS' from dual

  3. select '''TCS''' from dual

  4. select "TCS" from dual

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

In Oracle SQL, a single quote is escaped by doubling it. The expression '''||'TCS'||''' concatenates an escaped single quote, the string 'TCS', and another escaped single quote, resulting in 'TCS'.

Multiple choice technology databases
  1. select '''||'TCS ||''' from dual

  2. select '''TCS''' from dual

  3. select "TCS" from dual

  4. select 'TCS' from dual

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

To output literal single quotes around TCS, use two consecutive single quotes: '''TCS'''. In Oracle SQL, a single quote within a string is escaped by doubling it. The outer quotes define the string, inner pairs become literal quotes in output.

Multiple choice technology mainframe
  1. Name, DD, Space, Device

  2. Format, Name, DD, Space

  3. DD, parameter, device, format

  4. Name, DD, parameter, comments

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

A JCL DD statement consists of four fields in order: Name (the ddname), DD (the statement type), parameter (various parameters like DSN, DISP, SPACE), and comments (optional). Options A, B, and C either misorder the fields or include non-standard field names. 'Device' and 'format' are not among the four main fields.

Multiple choice technology databases
  1. foreign key constraint

  2. unique key constraint

  3. check constraint

  4. All of the above

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

Foreign key, unique key, and check constraints all permit NULL values by default unless they are explicitly paired with a NOT NULL constraint.

Multiple choice technology databases
  1. deletes data from table_name which cannot be rolled back

  2. deletes data from table_name but can be rolled back

  3. drops table_name

  4. none of the above

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

DELETE is a DML (Data Manipulation Language) command that can be rolled back using ROLLBACK if not committed. It removes data but preserves table structure. DROP TABLE removes the entire table (DDL, not rollable).

Multiple choice technology databases
  1. both column data type must be same

  2. both colmun data type need not be same

  3. one of the data type must be different

  4. both column data type and length must be same

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

A composite key combines multiple columns as a primary key. The columns can have different data types - there's no requirement for type matching. Only the combination of values must be unique.