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
-
Both values will be equal
-
Both values will not be equal
-
You can’t compare these two values
-
Both will be NULL
-
NO_DATA_FOUND
-
ROWTYPE_MISMATCH
-
TOO_MANY_ROW
-
DUP_VAL_ON_INDEX
-
INVALID_CURSOR
-
CURSOR_ALREADY_OPEN
-
TIMEOUT_ON_RESOURCE
-
SYS_INVALID_ROWID
B
Correct answer
Explanation
In PL/SQL, attempting to open a cursor that is already open raises the CURSOR_ALREADY_OPEN exception. This is a predefined exception that occurs when you try to open an already-open cursor without closing it first.
-
Language Integrated Query
-
Language Independent Query
-
Language Interrelated Query
-
None of the above
A
Correct answer
Explanation
LINQ stands for Language Integrated Query, a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. It allows querying data from arrays, enumerable classes, XML documents, relational databases, and third-party data sources using a uniform syntax.
-
Only Alias
-
Removing the unnecessary tables.
-
Aliases or context
-
Only Context
C
Correct answer
Explanation
In data transformation scenarios involving multiple pipelines or circular references, loops can be resolved by using aliases (alternative names for tables) or by providing context that clarifies which version of a table to use at each point in the data flow. Simply removing tables or using only one method is not sufficient - you need both options available depending on the complexity of the mapping.
-
If database is having field whose length is more than 255 characters,
-
While exporting data formatting is lost.
-
a&b
-
only b
C
Correct answer
Explanation
Crystal Reports has known limitations including field length restrictions where database fields exceeding 255 characters can cause issues, and formatting loss when exporting data to certain formats. These are two distinct constraints that users encounter when working with Crystal Reports. The answer combines both limitations, acknowledging they both exist as problems.
-
ADD
-
ADD NEW
-
INSERT
-
INSERT NEW
A
Correct answer
Explanation
The ADD clause is used with ALTER TABLE to insert a new column into an existing table. INSERT is used to add new rows, not columns. The correct SQL syntax is 'ALTER TABLE table_name ADD column_name data_type'.
-
SELECT * FROM Persons WHERE FirstName LIKE '%a'
-
SELECT * FROM Persons WHERE FirstName ='a'
-
SELECT * FROM Persons WHERE FirstName LIKE 'a%'
-
SELECT * FROM Persons WHERE FirstName='%a%'
C
Correct answer
Explanation
In SQL, the LIKE operator combined with the wildcard % is used for pattern matching. The pattern 'a%' matches any string that starts with the character 'a' followed by any sequence of characters. Other options either look for an exact match or look for strings ending with 'a'.
-
SELECT DIFFERENT
-
SELECT DISTINCT
-
SELECT UNIQUE
-
SELECT SEPARATE
B
Correct answer
Explanation
The SELECT DISTINCT statement is standard SQL syntax used to filter out duplicate rows and return only unique values from the query result. Commands like DIFFERENT, UNIQUE, and SEPARATE are not standard SQL keywords for removing duplicate records from a query result.
A
Correct answer
Explanation
The query uses the || operator to concatenate multiple address fields and string literals into a single output string. The alias 'Address' is assigned to this single combined expression, resulting in exactly one output column. Other options incorrectly count the source columns instead of the output columns.
-
It is a primary key for a Dimension table.
-
It is a system generated sequence numbers
-
It is a unique key
-
It is a foreign key for a FACT table.
B
Correct answer
Explanation
Surrogate keys are system-generated sequence numbers used as primary keys when natural keys don't exist. They're not foreign keys, dimension keys by definition, or necessarily unique (surrogate keys are always unique by design).
-
it'll display the result of which id=99999
-
no rows selected
-
Error
-
garbage value...
B
Correct answer
Explanation
The query contains id=99999 AND 1=0. Since 1=0 is always false, the entire WHERE condition evaluates to false regardless of the id value. SQL will return no rows, not an error. This is a valid query that simply matches no records.