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. testing

  2. null

  3. False

  4. error

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

The NVL function in Oracle SQL evaluates the first argument. If it is null, it returns the second argument. Since the first argument is null, the query returns the string 'testing'.

Multiple choice technology
  1. set break

  2. set pause

  3. set gap

  4. None of the Above

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

The SQL*Plus command SET PAUSE ON pauses display between pages, waiting for user input before continuing. SET BREAK controls page breaks, SET GAP is not a valid SQL*Plus command, and None of the Above is incorrect since SET PAUSE is the right answer.

Multiple choice technology
  1. having

  2. group by

  3. Where

  4. Both A. and B.

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

GROUP BY and HAVING are both group-related clauses in SQL. GROUP BY aggregates data into groups, while HAVING filters those groups after aggregation. WHERE filters individual rows before grouping, not groups themselves.

Multiple choice technology
  1. Views are windows of existing table

  2. Creation of view is done by using CREATE VIEW statement

  3. Views do not contain data but table from which it is created contain data

  4. All the Above

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

To answer this question, the user needs to have a basic understanding of Views in SQL.

A. This option is incorrect. Views are not windows of existing tables; rather, they are virtual tables that are created using a SELECT statement.

B. This option is correct. Views in SQL are created using the CREATE VIEW statement. This statement allows you to define a view based on a SELECT statement that retrieves data from one or more tables.

C. This option is also correct. Views do not contain any data themselves. Instead, they are virtual tables that are defined based on the data in one or more existing tables. Any changes made to the data in the underlying tables will be reflected in the view.

D. This option is correct. All of the above statements are true about views in SQL.

Therefore, the answer is: D. All the Above

Multiple choice technology web technology
  1. 01-01-1111

  2. Error

  3. 01

  4. 1111

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

In SQL databases like Oracle, SysDate returns a value of the DATE datatype. Performing division on a date value directly is an invalid operation and results in a datatype mismatch error. The distractors incorrect because they assume date arithmetic allows division resulting in modified date or numeric values.

Multiple choice technology
  1. -50

  2. 50

  3. -1

  4. 1

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

The SIGN function returns -1 for negative numbers, 0 for zero, and 1 for positive numbers. Since -50 is negative, SIGN(-50) returns -1, not the original value or its absolute value.

Multiple choice technology
  1. SELECT FROM EMP WHERE EMPNAME='RITA';

  2. SELECT FROM EMP MATCHING EMPNAME='RITA';

  3. SELECT * FROM EMP WHERE EMPNAME='RITA';

  4. SELECT # FROM EMP MATCHING EMPNAME='RITA';

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

SELECT * FROM EMP WHERE EMPNAME='RITA' correctly uses * for all columns and proper WHERE clause syntax. Options A and B are missing the * for all columns, while 'MATCHING' is not valid SQL syntax - WHERE clause should be used for filtering.

Multiple choice technology mainframe
  1. Search

  2. Search ALL

  3. In-Line Perform

  4. All of the above

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

For tables with fewer than 20 elements, an inline PERFORM VARYING is more efficient than binary search methods like SEARCH ALL. The overhead of setting up a table index for SEARCH/SEARCH ALL outweighs benefits for small datasets. Inline perform provides simple sequential access without additional table setup requirements.

Multiple choice technology mainframe
  1. 01 is record level

  2. No multiple record level fields

  3. Occurs repeat the fields only

  4. All of the above

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

The OCCURS clause cannot be used at 01 level because 01 represents the record definition itself, not a repeating field within a record. Multiple 01-level entries define separate record formats, not repeated fields. OCCURS is designed to repeat data items within a record structure, not repeat entire records. All these reasons combine to make 01-level OCCURS invalid in COBOL.

Multiple choice technology mainframe
  1. Using the CREATE parameter in a LIKE table statement

  2. Using the LIKE parameter

  3. Using the LIKE parameter in a CREATE table statement

  4. None of the above

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

A LIKE table is created using the LIKE parameter within a CREATE TABLE statement. The syntax is CREATE TABLE new-table LIKE existing-table, which copies the structure (column definitions) of an existing table. The LIKE parameter is specified within the CREATE statement itself, not as a separate parameter or standalone statement.

Multiple choice technology programming languages
  1. The SELECT clause designates query domain

  2. An EJB QL query may have parameters.

  3. The WHERE clause determines the types of objects to be selected

  4. Of the three clause types, SELECT, FROM and WHERE, only the SELECT clause is required

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

EJB QL (EJB Query Language) supports parameters in queries using positional syntax (?1, ?2, etc.). The FROM clause designates the query domain (the entity abstract schema types), not SELECT. The WHERE clause filters results but doesn't determine types - that's FROM's job. Both FROM and SELECT are typically required (SELECT can be optional only for aggregate queries).