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
-
key constraint violations
-
Loading nulls into a not null field
-
Database trigger responses
-
Lack of database space to load data
D
Correct answer
Explanation
Fatal errors in Informatica are conditions that completely stop session execution. Key constraint violations (A) and loading nulls into not-null fields (B) are data-level errors but don't always halt execution - they may be redirected or handled based on session settings. Database trigger responses (C) depend on trigger logic. However, lack of database space (D) is a system-level failure that cannot be handled within the session - it's truly fatal.
-
Script mode
-
Bulk mode
-
Query mode
-
Normal mode
A,C
Correct answer
Explanation
SQL transformation in Informatica can operate in Script mode (executes SQL scripts) or Query mode (executes single queries). Bulk mode and Normal mode are not valid execution modes for SQL transformation.
-
DELETE statements only
-
UPDATE, DELETE, INSERT and SELECT statements
-
UPDATE statements only
-
INSERT statements only
B
Correct answer
Explanation
SQL subqueries are versatile and can be nested within all four major DML statements: SELECT, INSERT, UPDATE, and DELETE. This allows for complex data manipulation where the inner query's results determine which rows are affected by the outer statement. For example, you can use a subquery in an UPDATE statement to filter rows based on values from another table, or in DELETE to remove rows matching specific criteria from a subquery.
-
INSERT Projects VALUES ('Content Development', 'Website content development project')
-
SAVE INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project')
-
INSERT INTO Projects (ProjectName, ProjectDescription) VALUES ('Content Development', 'Website content development project')
-
INSERT Projects ('Content Development', 'Website content development project')
C
Correct answer
Explanation
The correct SQL INSERT syntax requires the INSERT INTO clause, followed by the table name and optional column list in parentheses, then the VALUES keyword with matching data in parentheses. Option C demonstrates this correctly with proper column specification (ProjectName, ProjectDescription) and corresponding values. Options A and D are missing the INTO keyword and proper column structure, while option B incorrectly uses 'SAVE INTO' which is not valid SQL syntax.
-
ASC
-
DESC
-
No Default value
-
Returns error
A
Correct answer
Explanation
By default, the SQL ORDER BY clause sorts the query results in ascending order. If neither ASC (ascending) nor DESC (descending) is explicitly specified after the column name, ASC is applied automatically.
-
SELECT FROM Sales WHERE Date BETWEEN '10/12/2005' AND '01/01/2006'
-
SELECT * FROM Sales WHERE Date BETWEEN '10/12/2005' AND '01/01/2006'
-
SELECT FROM Sales WHERE Date BETWEEN ('10/12/2005', '01/01/2006')
-
All the above
B
Correct answer
Explanation
Option B is correct because it uses proper SQL syntax with SELECT * to retrieve all columns, and the BETWEEN operator correctly filters dates. Option A is missing the column specification (* or specific columns), and Option C has incorrect parentheses around the date values.
-
Order By
-
Sort
-
Arrange
-
All the above
A
Correct answer
Explanation
ORDER BY is the standard SQL clause for sorting query results. Options B and C are not valid SQL clauses for sorting.
-
SELECT ADD(Price) FROM Sales
-
SELECT TOTAL(Price) FROM Sales
-
SELECT SUM(Price) FROM Sales
-
SELECT SUM(Price) WHERE Sales
C
Correct answer
Explanation
SUM() is the standard SQL aggregate function for calculating the total of numeric values in a column. Option A uses a non-existent ADD() function, Option B uses TOTAL() which is not standard SQL, and Option D is missing the FROM clause.
-
The TRUNCATE clause deletes all rows in a database table, while the DELETE clause can have a WHERE condition and might or might not delete all rows in a table
-
The TRUNCATE clause is identical to the DELETE clause
-
The DELETE clause deletes all rows in a database table, while the TRUNCATE clause can have a WHERE condition and might or might not delete all rows in a table
-
None of these
A
Correct answer
Explanation
TRUNCATE removes all rows from a table without a WHERE clause and cannot be conditional, while DELETE can use WHERE to selectively remove rows. TRUNCATE is faster and resets identity values, whereas DELETE logs individual row deletions.
-
******3400
-
3400******
-
3400
-
Error
D
Correct answer
Explanation
The LPAD function requires the third parameter to be a string, not a literal asterisk character. The correct syntax would be LPAD(3400,10,'*') with quotes around the padding character. Using * without quotes causes a syntax error.
B
Correct answer
Explanation
TRUNC(760.5,-2) truncates to the hundreds place (negative second decimal position), resulting in 700. The negative parameter specifies truncation to the left of the decimal point.
C
Correct answer
Explanation
The Oracle NVL2 function evaluates the first expression. If it is not null, it returns the second expression, but if it is null, it returns the third expression.
-
SELECT * FROM Persons WHERE FirstName LIKE 'a%'
-
SELECT * FROM Persons WHERE FirstName LIKE '%a'
-
SELECT * FROM Persons WHERE FirstName='a'
-
SELECT * FROM Persons WHERE FirstName='%a%'
A
Correct answer
Explanation
The LIKE operator with 'a%' matches any string starting with 'a'. Option B would end with 'a', Option C is an exact match, and Option D would contain 'a' anywhere.
A
Correct answer
Explanation
A primary key can consist of multiple columns, known as a composite primary key. This is common when a single column cannot uniquely identify a row.
-
Hierarchical Database Model
-
Relational Database Model
-
Network Database Model
-
File Management Model
B
Correct answer
Explanation
SQL (Structured Query Language) is designed specifically for Relational Database Management Systems (RDBMS). The relational model, based on mathematical set theory, organizes data into tables with rows and columns, which SQL manipulates. SQL does not support Hierarchical or Network database models (these are older models), and File Management is a lower-level OS concept, not a data model.