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 mainframe
  1. Multiple Rows

  2. Single Row

  3. No Rows

  4. Null Value

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

SQLCODE -811 in DB2 indicates that a SELECT INTO statement or a subquery in a predicate returned more than one row, which is not allowed when a single row is expected. This error commonly occurs when using SELECT INTO without proper WHERE clause conditions to ensure uniqueness.

Multiple choice technology mainframe
  1. SRVCHNL

  2. SRVCTRC

  3. SRVCOOP

  4. SRVRNST

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

SRVCOOP is the designated table for storing option-related details in mainframe contract systems. The naming follows a convention where COOP likely represents cooperative options or option parameters.

Multiple choice technology databases
  1. having

  2. group by

  3. where

  4. both 1 and 2

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

In SQL, the GROUP BY clause is used to arrange identical data into groups, and the HAVING clause is used to filter groups after aggregation. Both are related to grouping operations - GROUP BY creates groups, HAVING filters them.

Multiple choice technology databases
  1. Gives the columns referred in select statement of view

  2. Reports a error

  3. Select only particular columns of view table

  4. Outputs the whole view table

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

A view is a virtual table that dynamically retrieves data from its base table. If the underlying base table is dropped or deleted, the view becomes invalid. Subsequent query attempts on the view will fail and report an error since the source data structure no longer exists.

Multiple choice technology databases
  1. Long

  2. Date

  3. rowid

  4. all above

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

SQL supports various data types including Date for date values and rowid as a pseudo-column that uniquely identifies rows. 'Long' is not a standard SQL data type (it exists in Oracle as NUMBER subtype but not as a keyword). The question tests SQL data type awareness.

Multiple choice technology databases
  1. GENERATE SEQUENCE SE START WITH 30 ADD BY 20;

  2. CREATE SEQUENCE SE START WITH 30 ADD BY 20;

  3. CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20;

  4. GENERATE SEQUENCE SE INITIATE WITH 30 INCREMENT BY 20;

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

The standard SQL syntax to define a sequence with a custom start value and step increment uses CREATE SEQUENCE combined with the START WITH and INCREMENT BY clauses. The other options use invalid keywords such as GENERATE, ADD BY, or INITIATE WITH.

Multiple choice technology databases
  1. Same value of Primary Key can appear in more than one row in the table

  2. A Primary key defined column can be of type LONG

  3. A column that is defined as Primary Key cannot contain NULL value

  4. Both A. and B.

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

A Primary Key uniquely identifies each row in a table and cannot contain NULL values. This ensures entity integrity. Primary Key values must be unique across all rows, making option A incorrect. LONG is not a standard SQL type for primary keys.

Multiple choice technology databases
  1. Table name can be an oracle reserved word

  2. Table names must begin with a letter

  3. Table names can contain in it numbers also

  4. None of the Above

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

When creating tables in SQL using CREATE TABLE, table names should not be reserved words as this causes parsing errors. While you can sometimes use quoted identifiers to bypass this, best practice is to avoid reserved words entirely. Table names must begin with a letter.

Multiple choice technology programming languages
  1. SqldataAttribute

  2. SqlClientPermissionAttribute

  3. SecqurityAttribute

  4. None of these

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

SqlClientPermissionAttribute is used in .NET Code Access Security (CAS) to restrict SQL operations in partial-trust scenarios. It allows specifying required permissions for methods that access SQL Server, ensuring security in restricted environments.

Multiple choice technology programming languages
  1. Dim query = From product In products.AsEnumerable() Select product

  2. Dim query as select product From product In products.AsEnumerable()

  3. Dim query = From p In products.AsEnumerable() Select p

  4. None of these

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

Option A correctly uses LINQ to DataSet syntax in VB.NET with AsEnumerable() to enable LINQ queries on DataTable rows. The Select clause returns all product rows which can then be iterated to display product names. Option B has invalid syntax, Option C uses a different alias but doesn't address displaying names specifically.

Multiple choice technology programming languages
  1. Commit();

  2. Update();

  3. SubmitChanges();

  4. CommitTransaction();

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

LINQ to SQL uses SubmitChanges() to write pending insert, update, and delete operations to the database. The framework tracks changes to entities and automatically generates and executes appropriate SQL commands when SubmitChanges() is called. The other methods are not part of LINQ to SQL.