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
-
Intersection
-
Difference
-
Projection
-
Selection
-
JOIN
B
Correct answer
Explanation
The difference operation is used for removing common tuples from first relation.
-
GROUP BY
-
COUNT
-
SUM
-
AVG
-
ORDER BY
E
Correct answer
Explanation
This is used to arrange the result of a query in either ascending (ASC) or descending order (DESC).
-
BETWEEN predicate
-
LIKE predicate
-
IN predicate
-
COUNT
-
SUM
A
Correct answer
Explanation
BETWEEN predicate is used to specify the range in which the value must lie.
-
IN predicate
-
LIKE predicate
-
GROUP-BY
-
COUNT
-
SUM
B
Correct answer
Explanation
Pattern matching can be done using LIKE predicate. In pattern matching, string constant is compared with a column of type character.
B
Correct answer
Explanation
ANY stands for existential quantifier.
-
Difference or minus
-
Sum
-
Cartesian product
-
Projection
-
Selection
A
Correct answer
Explanation
It removes common tuples from first relation.
-
Count
-
Union
-
Intersection
-
Projection
-
Selection
C
Correct answer
Explanation
This operation selects the common tuples from two relations.
-
Attribute
-
Candidate key
-
Foreign key
-
Primary key
-
Entity
C
Correct answer
Explanation
Reference to a table through the primary key of that related table is achieved using foreign key.
-
Domain constraint
-
Super key
-
Candidate key
-
Primary key
-
Attribute
A
Correct answer
Explanation
Domain constraints specifies that within each tuple, the value of each attribute must be an atomic value.
-
Character string length is maximum 2000 bytes.
-
There are no reference data types defined for Oracle database.
-
The array data type is ordered type.
-
long raw comes under the collection data types.
-
Both (2) and (4)
E
Correct answer
Explanation
These are theĀ false statements.
-
COMMIT
-
DROP
-
ROLLBACK
-
SAVEPOINT
C
Correct answer
Explanation
ROLLBACK is the SQL command that undoes all changes made during the current transaction, restoring the database to its state before the transaction began. COMMIT permanently saves changes, while DROP deletes database objects and SAVEPOINT marks intermediate points within a transaction.
-
rules to prevent invalid data entry
-
rules to write programs in SQL
-
rules to create user-defined data type in SQL
-
none of these
A
Correct answer
Explanation
Constraints in SQL are rules enforced on table columns to ensure data integrity and prevent invalid data entry. Common constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK. They are not used for writing programs or creating data types.
-
foreign key
-
duplicate key
-
alternate key
-
composite key
D
Correct answer
Explanation
A composite key is a primary key that consists of two or more columns used together to uniquely identify each record in a table. A foreign key references another table's primary key, an alternate key is a candidate key not chosen as primary key, and 'duplicate key' is not a standard database term.
-
UNIQUE
-
DISTINCT
-
CHECK
-
None of these
A
Correct answer
Explanation
The UNIQUE constraint ensures that all values in a column are different - no two rows can have the same value for that column. DISTINCT is used in SELECT queries to remove duplicates from results, CHECK validates values against a condition, and these are not the correct constraint for preventing repeated values.
-
contain NULL VALUES
-
contain repetitive values
-
contain NULL as well as repetitive values
-
none of these
D
Correct answer
Explanation
A PRIMARY KEY must contain unique values and cannot contain NULL values. Option D 'none of these' is correct because options A, B, and C all describe what a primary key must NOT do - it cannot contain NULL values, cannot contain repetitive values, and certainly cannot contain both.