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
B
Correct answer
Explanation
Database sort order MUST match session sort order in Informatica. If they differ, you may get inconsistent sorting results and data ordering issues. This alignment ensures consistent behavior across the ETL pipeline.
-
Multiple Rows
-
Single Row
-
No Rows
-
Null Value
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.
-
SRVCTRC
-
SRVCHNL
-
SRVADJT
-
SRVCOOP
A
Correct answer
Explanation
In mainframe contract management systems, SRVCTRC is the standard table storing contract status information. The naming convention suggests SRVC for service contracts and TRC for tracking or status records.
-
SRVCHNL
-
SRVCTRC
-
SRVCOOP
-
SRVRNST
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.
-
having
-
group by
-
where
-
both 1 and 2
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.
-
Gives the columns referred in select statement of view
-
Reports a error
-
Select only particular columns of view table
-
Outputs the whole view table
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.
-
Long
-
Date
-
rowid
-
all above
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.
-
GENERATE SEQUENCE SE START WITH 30 ADD BY 20;
-
CREATE SEQUENCE SE START WITH 30 ADD BY 20;
-
CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20;
-
GENERATE SEQUENCE SE INITIATE WITH 30 INCREMENT BY 20;
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.
-
Same value of Primary Key can appear in more than one row in the table
-
A Primary key defined column can be of type LONG
-
A column that is defined as Primary Key cannot contain NULL value
-
Both A. and B.
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.
-
Table name can be an oracle reserved word
-
Table names must begin with a letter
-
Table names can contain in it numbers also
-
None of the Above
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.
-
SqldataAttribute
-
SqlClientPermissionAttribute
-
SecqurityAttribute
-
None of these
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.
-
Dim query = From product In products.AsEnumerable() Select product
-
Dim query as select product From product In products.AsEnumerable()
-
Dim query = From p In products.AsEnumerable() Select p
-
None of these
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.
-
Commit();
-
Update();
-
SubmitChanges();
-
CommitTransaction();
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.