Nothing Special   »   [go: up one dir, main page]

SQL MCQ

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

CORRECT

Which one of the following sorts rows in SQL?

SORT BY
ALIGN BY
ORDER BY
GROUP BY

CORRECT

Which of the following is NOT a SQL constraint?

PRIMARY KEY
ALTERNATE KEY
FOREIGN KEY
UNIQUE

CORRECT

Write an SQL query to find names of employee starting with ‘A’? Table name: Employee and
column name: EmpName

select *
from Employee
where EmpName like 'a%';

CORRECT

There is an error in the query given below. How can we correct it?

SELECT subject_code, AVG (marks)

FROM students

WHERE AVG(marks) > 75

GROUP BY subject_code;

select subject_code,avg(marks)
from students
group by subject_code
having avg(marks)>75

CORRECT

What are different types of joins in SQL?

inner join
left outer join/left join
right outer join/right join
full outer join/full join
cartesian product/cross join
self join

CORRECT

Which data type can store unstructured data in a column?

RAW
CHAR
NUMERIC
VARCHAR

CORRECT

The SQL wildcards are ____ and ____ .

asterisk (*); percent sign (%)


percent sign (%); underscore (_)
underscore(_); question mark (?)
question mark (?); asterisk (*)

CORRECT

What are the different types of SQL commands?

DDL - data definition language


dml - data manipulation language
tcl - transaction control language
dcl - data control language

CORRECT

What are different types on constraints in SQL?

NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT

WRONG

The command used to delete a particular column in a relation is [DELETE


COLUMN (ALTER DROP)]

CORRECT

What is the full form of DDL?

Dynamic Data Language


Detailed Data Language
Data Definition Language
Data Derivation Language

CORRECT

A database language used for defining the whole database structure and schema is called:

DCL
DML
DDL
ALL OF THE ABOVE
CORRECT

Which data manipulation command is used to combine the records from one or more
tables?

SELECT
JOIN
PROJECT
PRODUCT

WRONG

What is the sequence of execution of below query:

SELECT DISTINCT column, AGG_FUNC(column_or_expression), …

FROM mytable

JOIN another_table

ON mytable.column = another_table.column

WHERE constraint_expression

GROUP BY column

HAVING constraint_expression

ORDER BY column ASC/DESC

LIMIT count OFFSET COUNT;

 FROM

 JOIN [WHERE]

 WHERE [JOIN]

 GROUP BY

 HAVING [SELECT]

 ORDER BY [HAVING]

 LIMIT [ORDER BY]

 SELECT [LIMIT]
CORRECT

What is the meaning of '%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

CORRECT

.A SQL query automatically eliminates duplicates (True / False) ?

TRUE
FALSE

CORRECT

What’s wrong in the following query?

SELECT subject_code, count(name)

FROM students;

SELECT subject_code , count(name)


from students
group by subject_code
order by subject_code

CORRECT

Which operator is used to compare a value to a specified list of values?

BETWEEN
ANY
IN
ALL

CORRECT

The COUNT function in SQL returns the number of [VALUES]

CORRECT

The SQL keyword [LIKE Only] is used with wildcards.

CORRECT

Which function is used to divides one numeric expression by another and get the
remainder?

POWER
MOD
ROUND
REMAINDER

CORRECT

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

CORRECT

The virtual table that is created by data from the result of an SQL 'Select' statement is called
[VIEW]

CORRECT

How is UNION ALL different from UNION?


UNION removes duplicate rows whereas UNION ALL does not
UNION has to perform distinct sort to remove duplicates. which makes it less faster than
UNION ALL

CORRECT

Which statement in SQL allows us to change the definition of a table is?

ALTER
UPDATE
CREATE
SELECT

WRONG

Which of the following is a comparison operator in SQL?

Double equal sign ( == )


LIKE
BETWEEN
Single equal sign ( = )

CORRECT

Which of the following is not a valid SQL type?

DECIMAL
NUMERIC
FLOAT
CHARACTER

CORRECT

Which of the following is a legal expression in SQL?

SELECT NULL FROM SALES;


SELECT NAME FROM SALES;
SELECT * FROM SALES WHEN PRICE = NULL;
SELECT # FROM SALES;

You might also like