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
-
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.
-
CREATE INTO
-
SELECT INTO
-
CREATE FROM
-
NONE OF THESE
B
Correct answer
Explanation
SELECT INTO is a SQL command (particularly in SQL Server) that creates a new table and populates it with the result set from a query, effectively creating a backup. CREATE INTO and CREATE FROM are not valid SQL syntax for this purpose.
-
is used with the DISTINCT SQL keyword only
-
is used with the INSERT SQL keyword only
-
determines if a value matches any of the values in a list or a sub-query
-
defines the tables we are selecting or deleting data from
C
Correct answer
Explanation
The IN operator in SQL tests whether a value matches any value in a specified list or any value returned by a subquery. It is not limited to DISTINCT or INSERT keywords, and FROM (not IN) defines the tables for SELECT or DELETE operations.
-
update only one row at a time
-
update more than one row at a time
-
delete more than one row at a time
-
delete only one row at a time
B
Correct answer
Explanation
The UPDATE statement modifies all rows that satisfy the WHERE clause. If the WHERE condition matches multiple rows (or is omitted entirely), the UPDATE affects all matching rows simultaneously, not just one.
-
Disable the triggers while performing the import process.
-
Drop the triggers before the import process, and then recreate them.
-
Use appropriate arguments while performing the import process to disable the firing of triggers.
-
Do nothing because the triggers will not be fired when you perform an import by using the bcp utility.
D
Correct answer
Explanation
The bcp (bulk copy program) utility in SQL Server bypasses triggers by default for performance. During bulk import operations, triggers are not fired unless specifically configured otherwise.
-
Structured Query Language
-
Sequential Query Language
-
Standard Query Language
-
Simple Query Language
A
Correct answer
Explanation
SQL is an industry-standard language designed for managing and manipulating relational databases. The name literally describes its purpose: a structured language for querying data.
-
INSERT
-
CREATE
-
UPDATE
-
COMMIT
B
Correct answer
Explanation
DDL (Data Definition Language) defines database structures. CREATE builds objects like tables, views, and indexes. INSERT and UPDATE are DML (data manipulation), while COMMIT is TCL (transaction control).
-
locate records quickly
-
locate a table quickly
-
to create a back up table
-
none of these
A
Correct answer
Explanation
Indexes create data structures that allow the database engine to find specific rows quickly without scanning entire tables. They optimize record retrieval based on column values.
-
ZERO
-
BLANK
-
NULL
-
NONE OF THESE
C
Correct answer
Explanation
In SQL databases, a column with no value stores NULL, which represents missing or unknown data. NULL is different from zero, a blank string, or an empty value - it is the absence of a value.
-
NEW
-
INSERT
-
ADD
-
NONE OF THESE
B
Correct answer
Explanation
INSERT is the standard SQL command for adding new records (rows) to a table. It specifies which table to modify and provides values for the columns.
-
MODIFY
-
CHANGE
-
UPDATE
-
EDIT
C
Correct answer
Explanation
UPDATE modifies existing data in a database. It changes values in specified columns for rows that match the WHERE condition, allowing targeted changes to existing records.
A
Correct answer
Explanation
DROP completely removes a table and its structure from the database, including all data, indexes, and constraints. DELETE removes only the data rows while preserving the table structure.