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
-
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.
-
The TRUNCATE clause is identical to the DELETE 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.
-
None fo the above
C
Correct answer
Explanation
TRUNCATE is a DDL operation that quickly removes all rows from a table and cannot use a WHERE clause. In contrast, DELETE is a DML operation that can target specific rows using a WHERE condition. The other options incorrectly swap these behaviors or claim the commands are identical.
-
Creates a database view
-
Creates a new database table
-
Creates a stored procedure
-
Creates a trigger
-
A trigger is part of data extraction process.
-
A trigger is a special kind of stored procedures executed when certain event occurs.
-
A trigger defines relations between tables.
-
A trigger is a part of error handling
-
List of columns that will be selected or the * symbol.
-
The JOIN SQL clause.
-
The name of the table we are selecting from.
-
Selects a database
A
Correct answer
Explanation
The SELECT clause is immediately followed by the list of column names to retrieve or the asterisk (*) wildcard for all columns. The FROM clause specifying the table comes after SELECT.
-
Having Clause
-
Where clause
-
Distinct
-
Exists
A
Correct answer
Explanation
HAVING clause filters groups after aggregation, while WHERE clause filters individual rows before grouping. HAVING is used to specify conditions on the groups created by GROUP BY, such as showing only categories with total sales above a threshold. WHERE cannot be used with aggregate functions, whereas HAVING can.
-
Work as primary key
-
Uniquely identify the records
-
show a relation between the primary key and unique key
-
All of the above
-
None of these
E
Correct answer
Explanation
Identity columns are auto-incrementing columns that automatically generate unique numeric values for new rows. While they often serve as primary keys, that's not their definition - they're specifically about auto-generated sequential values. Options A, B, and C describe possible USES or characteristics, not the definition. The question asks 'what IS', not 'what does it DO', making 'None of these' the technically correct answer as none define what an identity column fundamentally is.
-
DML Trigger
-
Instead of Trigger
-
DDL Trigger
-
Nested Trigger
C
Correct answer
Explanation
DDL (Data Definition Language) triggers fire when CREATE, ALTER, DROP, GRANT, DENY, REVOKE, or sp_rename statements are executed on database objects. DML triggers respond to INSERT, UPDATE, DELETE operations on data. INSTEAD OF triggers replace the triggering action. Nested triggers refer to trigger chains, not a specific type.
-
Change the primary key index to clustered and create a nonclustered index on the address
-
Create a nonclustered index on the address.
-
Create a clustered index on the address.
-
Change the primary key to the address and make the index clustered.
C
Correct answer
Explanation
A clustered index determines the physical order of data in the table. To put data into address sequence, you need a clustered index on the address fields. Only one clustered index can exist per table (unlike nonclustered indexes), and the primary key's nonclustered index doesn't prevent creating another clustered index on a different set of columns.
C
Correct answer
Explanation
MIN is an aggregate function that returns the smallest value in a column. DOWN and LOW are not SQL keywords for finding minimum values. LOWER is a string function that converts text to lowercase, unrelated to finding minimum numerical values.
-
ON
-
OFF
-
NULL
-
None of the options
B
Correct answer
Explanation
PAD_INDEX option determines whether the intermediate levels of the index are padded. In SQL Server, the default value for PAD_INDEX is OFF, meaning intermediate levels are not padded to fill percentage. When ON, it uses the same fillfactor value as the leaf level.
B
Correct answer
Explanation
In the INSYNC utility, the SHADOW batch keyword determines whether fields excluded from the selection are displayed as shadow lines in the report. Other keywords like SEARCH, STRIP, and FIND perform different functions, such as locating data or removing characters, rather than controlling the reporting of excluded fields.
-
GRQ
-
GRQUALITY
-
GRQ12
-
ALL THE ABOVE
A
Correct answer
Explanation
Oracle System Identifiers (SIDs) must be alphanumeric, start with a letter, and have a maximum length of 12 characters. 'GRQ' meets all these requirements. 'GRQUALITY' exceeds 12 characters and 'GRQ12' contains numbers (though some sources allow numbers, strict SID naming typically prefers alphanumeric).
A
Correct answer
Explanation
You CAN use both SELECT and WHERE in one SQL statement - this is the standard pattern for filtering data. SELECT specifies columns to retrieve, and WHERE filters which rows to return. They work together in queries like 'SELECT name FROM users WHERE age > 18'.
-
The AS SQL clause is used change the name of a column in the result set or to assign a name to a derived column.
-
The AS clause is used with the JOIN clause only.
-
The AS clause defines a search condition.
-
The AS clause defines a group
A
Correct answer
Explanation
The AS clause is used to alias columns - either renaming existing columns in results (SELECT col AS new_name) or naming derived columns (SELECT price * qty AS total). It makes output more readable and allows referencing computed values by name.
-
SELECT * FROM Contest WHERE ContestDate >= '05/25/2006'
-
SELECT * FROM Contest HAVING ContestDate >= '05/25/2006'
-
SELECT * FROM Contest WHERE ContestDate < '05/25/2006'
-
SELECT * FROM Contest IN ContestDate < '05/25/2006'
A
Correct answer
Explanation
SELECT * FROM Contest WHERE ContestDate >= '05/25/2006' is correct. The WHERE clause filters rows based on the date condition, and >= selects dates on or after May 25, 2006. Option C uses < (wrong direction), B uses HAVING (for aggregated data), and D has invalid syntax.