50 questions
Which data manipulation command is used to combines the records from one or more tables?
SELECT
PROJECT
JOIN
PRODUCT
Which operator is used to compare a value to a specified list of values?
BETWEEN
ANY
IN
ALL
Which of the following operations requires the relations to be union compatible?
UNION
INTERSECTION
DIFFERENCE
ALL OF THESE
DCL provides commands to perform actions like
Change the structure of Tables
Insert, Update or Delete Records and Values
Authorizing Access and other control over Database
None of Above
Which function is used to divides one numeric expression by another and get the remainder ?
POWER
MOD
ROUND
REMAINDER
A database language used for defining the whole data base structure and schema is called
DCL
DML
DDL
All Of Above
Which statement in SQL allows us to change the definition of a table is?
ALTER
UPDATE
CREATE
SELECT
Which operator performs pattern matching?
BETWEEN operator
LIKE operator
EXISTS operator
None of these
In SQL, which command is used to SELECT only one copy of each set of duplicable rows
SELECT UNIQUE
SELECT DISTINCT
SELECT DIFFERENT
All of the above
Which SQL keyword is used to
retrieve a maximum value?
TOP
MOST
UPPER
MAX
Which of the following is a SQL aggregate function?
LEFT
AVG
JOIN
LEN
Which SQL keyword is used to sort the result-set?
SORT BY
ORDER
ORDER BY
SORT
Which of the following group functions ignore NULL values?
MAX
COUNT
SUM
All of the above
Table Employee has 10 records. It
has a non-NULL SALARY column which is also UNIQUE.
The SQL statement
SELECT COUNT(*) FROM Employee WHERE SALARY > ANY (SELECT SALARY FROM
EMPLOYEE);
prints
10
9
5
0
The SQL statement
SELECT SUBSTR('abcdefghij', INSTR('123321234', '2', 3, 2), 2) FROM DUAL;
prints
ij
bc
ab
gh
Find all the cities whose humidity is 89
SELECT city WHERE humidity = 89;
SELECT city FROM weather WHERE humidity = 89;
SELECT humidity = 89 FROM weather;
SELECT city FROM weather;
What is the meaning of LIKE
'%0%0%'
Feature begins with two 0's
Feature ends with two 0's
Feature has more than two 0's
Feature has two 0's in it, at any position
Find the names of those cities with temperature and condition whose condition is neither sunny nor cloudy
SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN ('sunny', 'cloudy');
SELECT city, temperature, condition FROM weather WHERE condition IN ('sunny', 'cloudy');
SELECT city, temperature, condition FROM weather WHERE condition NOT IN ('sunny', 'cloudy');
SELECT city, temperature, condition FROM weather WHERE condition BETWEEN ('sunny', 'cloudy');
Find the name of those cities with temperature and condition whose condition is either sunny or cloudy but temperature must be greater than 70oF.
SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' OR temperature > 70;
SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' OR temperature > 70;
SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' AND temperature > 70;
SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' AND temperature > 70;
Find all the cities with temperature, condition and humidity whose humidity is in the range of 63 to 79
SELECT * FROM weather WHERE humidity IN (63 to 79)
SELECT * FROM weather WHERE humidity NOT IN (63 AND 79)
SELECT * FROM weather WHERE humidity BETWEEN 63 AND 79
SELECT * FROM weather WHERE humidity NOT BETWEEN 63 AND 79
What does the following query find?
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'red')
MINUS
(SELECT DISTINCT r.sid
FROM boats b, reserves r
WHERE b.bid = r.bid
AND b.color = 'green')
Find the sailor IDs of at least one sailor who have reserved red boats but not green boats
Find the sailor Ids of atmost one sailor who have reserved red boats but not green boats
Find the sailor IDs of all sailors who have reserved red boats but not green boats
None
Let the statement
SELECT column1 FROM myTable;
return 10 rows. The statement
SELECT ALL column1 FROM myTable;
will return
less than 10 rows
more than 10 rows
exactly 10 rows
None of these
Which of the following join is also called as an 'inner-join'?
Non-Equijoin
Self-Join
Equijoin
None of these
Which of the following is NOT a type of SQL constraint?
PRIMARY KEY
ALTERNATE KEY
FOREIGN KEY
UNIQUE
What is an SQL virtual table that is constructed from other tables?
A relation
Just another table
Query results
view
The SQL ALTER statement can be used to:
change the table data.
change the table structure.
delete rows from the table.
add rows to the table.
What SQL command can be used to delete columns from a table?
MODIFY TABLE TableName DROP ColumnName
MODIFY TABLE TableName DROP COLUMN ColumnName
ALTER TABLE TableName DROP ColumnName
ALTER TABLE TableName DROP COLUMN ColumnName
The command to remove rows from a table 'CUSTOMER' is:
DROP FROM CUSTOMER ...
UPDATE FROM CUSTOMER ...
REMOVE FROM CUSTOMER ...
DELETE FROM CUSTOMER WHERE ...
The SQL WHERE clause:
limits the row data are returned.
limits the column data that are returned.
Both A and B are correct.
Neither A nor B are correct.
The wildcard in a WHERE clause is useful when?
An exact match is not possible in a CREATE statement.
An exact match is necessary in a CREATE statement.
An exact match is necessary in a SELECT statement.
An exact match is not possible in a SELECT statement.
The SQL keyword(s) ________ is
used with wildcards.
NOT IN only
LIKE only
IN only
IN and NOT IN
A subquery in an SQL SELECT statement is enclosed in:
parenthesis -- (...).
brackets -- [...].
CAPITAL LETTERS.
braces -- {...}.
The HAVING clause does which of the following?
Acts EXACTLY like a WHERE clause.
Acts like a WHERE clause but is used for columns rather than groups.
Acts like a WHERE clause but is used for groups rather than rows.
Acts like a WHERE clause but is used for rows rather than columns.
Which of the following query is correct for using comparison operators in SQL?
SELECT name, course_name FROM student WHERE age>50 and <80;
SELECT name, course_name FROM student WHERE age>50 and age <80;
SELECT name, course_name FROM student WHERE age>50 and WHERE age<80;
None of these
How to select all data from student table starting the name from letter 'r'?
SELECT * FROM student WHERE name LIKE 'r%';
SELECT * FROM student WHERE name LIKE '%r%';
SELECT * FROM student WHERE name LIKE '%r';
SELECT * FROM student WHERE name LIKE '_r%';
Which statement is wrong about PRIMARY KEY constraint in SQL?
The PRIMARY KEY uniquely identifies each record in a SQL database table
Primary key can be made based on multiple columns
Primary key must be made of any single columns
Primary keys must contain UNIQUE values.
Wrong statement about UPDATE keyword is
If WHERE clause in missing in statement the all records will be updated.
Only one record can be updated at a time using WHERE clause
Multiple records can be updated at a time using WHERE clause
None is wrong statement
Wrong statement about ORDER BY keyword is
Used to sort the result-set in ascending or descending order
The ORDER BY keyword sorts the records in ascending order by default.
To sort the records in ascending order, use the ASC keyword.
To sort the records in descending order, use the DECENDING keyword.
Correct syntax query syntax to drop a column from a table is
DELETE COLUMN column_name;
DROP COLUMN column_name;
ALTER TABLE table_name DROP COLUMN column_name;
None is correct.
If you want to allow age of a person > 18 in the column Age of table Person, then which constraint will be applied to AGE column.
Default
Check
NOT NULL
None
Which SQL Join is used for joining the table itself?
Left Join
Self-Join
Natural join
Left Join
Which of the following is the correct order of keywords for SQL SELECT statements?
SELECT,WHERE,FROM
WHERE, FROM,SELECT
SELECT, FROM, WHERE
FROM, WHERE, SELECT
Which of the following are the five built-in functions provided by SQL?
SUM, AVG, MIN, MAX, MULT
SUM, AVG, MULT, DIV, MIN
SUM, AVG, MIN, MAX, NAME
COUNT, SUM, AVG, MAX, MIN
Find the SQL statement below that is equal to the following: SELECT NAME FROM CUSTOMER WHERE STATE = 'VA';
SELECT NAME IN CUSTOMER WHERE STATE IN ('VA');
SELECT NAME IN CUSTOMER WHERE STATE = 'VA';
SELECT NAME FROM CUSTOMER WHERE STATE = 'V%';
SELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');
SQL is:
a programming language.
an operating system.
a data sublanguage.
a DBMS.
Which product is returned in a join query have no join condition:
Equijoins
Cartesian
Both Equijoins and Cartesian
None of the mentioned
Which join refers to join records from the right table that have no matching key in the left table are include in the result set:
Left join
Right join
Full join
Half outer join
The intersection operator is used to get the _____ tuples.
Different
Common
All
Repeating
_____ clause is an additional filter that is applied to the result.
Select
Group-by
Having
Order by
What are composite indexes?
Are those which are composed by database for its internal use
A composite index is a combination of index on 2 or more columns
Composite index can never be created
None of the mentioned