My SQL MCQ

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

OBJECTIVE TYPE QUESTIONS

Multiple Choice Questions


1. A is a property of the entire relation, which ensures through its value that each tuple is unique in a relation.
(a) Rows (b) Key (c) Attributes (d) Fields

2. A relational database can have how many type of keys in a table?


a.Candidate Key (b) Primary Key (c) Foreign Key (d) All of these

3. Which one of the following uniquely identifies the tuples / rows in a relation.
a.Secondary Key (b) Primary Key (c) Composite Key (d) Foreign Key

4. The Primary key is selected from the set of .


a.Composite Key (b) Determinants (c) Candidates Key (d) Foreign Key

5. Which of the following is a group of one or more attributes that uniquely identifies a row?
(b) Key (b) Determinant (c) Tuple(d) Relation

6. An attribute in a relation is a foreign key if it is the key in any other relation.


a.Candidate (b) Primary (c) Super (d) Sub

7. Consider the table with structure as :


Student(ID, name, dept_name, tot_cred)
In the above table, which attribute will form the primary key?
a.name (b) dept_name (c) Total_credits (d) ID

8. Which of the following is not a legal sub-language of SQL ?


a.DDL (b) QAL (c) DML (d) TCL

9. Which of the following is a DDL command?


a.SELECT (b) ALTER (c) INSERT (d) UPDATE

10. In SQL, which of the following will select only one copy of each set of duplicate rowsfrom a table.
a)SELECT UNIQUE b) SELECT DISTINCT c)SELECT DIFFERENT d)All of these.
11. Which of the following keywords will you use in the following query to display the unique
values of the column dept_name?
SELECT dept_name FROM COMPANY;
a.All (b) From (c) Distinct (d) Name
12. The clause of SELECT query allows us to select only those rows in the result that
satisfy a specified condition.
a.where (b) from (c) having (d) like
13. Which operator can take wild card characters for query condition?
(a) BETWEN (b) LIKE (c) IN (d) NOT

14. Which operator checks a value against a range of values?


a.BETWEEN (b) LIKE (c) IN (d) NOT

15. Which of the following SQL commands retrives data from table(s) ?
a.UPDATE (b) SELECT (c) Union (d) All of these

16. Which of the following queries contains an error ?


a. Select * from emp where empid=10003;
b. Select empid from emp where empid=10006;
c. Select empid from emp;
d. Select empid where empid=10009 and lastname= ‘GUPTA’;
17. Consider the following table namely Employee :
Employee_id Name Salary
1001 Misha 6000
1009 Khushi 4500
1018 Japneet 7000
18. Which of the names will not be displayed by the below given query ?SELECT name from
Employee WHERE employee_id>1009;
a.Misha, Khushi (b) Khushi, Japneet (c) Japneet (d)Misha, Japneet
19. Which operator perform pattern matching?
a.BETWEN (b) LIKE (c) IN (d) NOT
20. Consider the following query
SELECT name FROM class WHERE Subject LIKE ‘ Informatics Practices’;
Which one of the following has to be added into the blank space to select the subject whichhas
informatics practices as its ending string?
(a) $ (b) _ (c) || (d) %
21. Which operator tests a column for the absence of data(i.e. NULL value) ?
a) Exist Operator (b) NOT Operator (c) IS Operator (d) None of these
22. . Which clause is used to sort the query result ?
a) Order By (b) Sort By (c) Group By (d) Arrange By
23. By default ORDER BY clause list the result in order.
a. Descending (b) Any(c) Same (d) Ascending
24. Consider the following query
SELECT * FROM employee ORDER BY salary , name ;
To display the salary from greater to smaller and name in alphabetical order which of thefollowing options
should be used ?
(a) Ascending, Descending
(b) Asc, Desc
(c) Desc, Asc
(d) Descending, Ascending
25. What is the meaning of Remark LIKE “%5%5%”;
a) Column Remark begin with two 5s
b) Column Remark ends with two 5s
c) Column Remark has more than two 5s
d) Column Remark has two 5s in it, at any position
26. In SQL, which command(s) is/are used to change a table’s structure/characteristics?
a.ALTER TABLE (b) MODIFY TABLE (c) CHANGE TABLE (d) All of these
27. Which of the following is/are the DDL Statement ?
a. Create (b) Drop (c) Alter (d) All of these
28. A Table can have
a) Many primary keys and many unique keys.
b) One primary key and one unique key
c) One primary key and many unique keys.
d) Many primary keys and one unique key.
29. Which of the following types of table constraints will prevent the entry of duplicate rows?
a. Unique (b) Distinct (c) Primary Key (d) Null
30. Consider the following SQL Statement. What type of statement is this ?
INSERT INTO instructor VALUES (10211, ‘SHREYA’ , ‘BIOLOGY’, 69000);
a. Procedure (b) DML (c) DCL (d) DDL
31. Which of the following statements will delete all rows in a table namely mytable without deleting the table’s
structure.
a. DELETE FROM mytable;
b. DELETE TABLE mytable;
c. DROP TABLE mytable;
d. None of these.
32. Which of the following query will drop a column from a table ?
a. DELETE COLUMN column_name;
b. DROP COLUMN column_name;
c. ALTER TABLE table_name DROP COLUMN column_name;
d. None of these
33. Logical operator used in SQL are:
a. AND, OR, NOT (b) &&, ||, ! (c) $,|,! (d) None of these
34. Which of the following requirement can be implemented using a CHECK constraint?
a. Student must be greater than 18 years old.
b. Student must be form a BRICS Country (Brazil, Russia, India, China, SouthAfrica)
c. Student’s roll number must exist in another table(say, namely Eligible)
d. None of these
35. An attribute in a relation is termed as a foreign key when it reference the of another relation.
a. Foreign Key (b) Primary Key (c) Unique Key (d) Check Constraint
36. Data integrity constraints are used to :
a. Control the access and rights for the table data.
b. Ensure the entry of unique records in a table.
c. Ensure the correctness of the data entered in the table as per some rule or
condition etc.
d. Make data safe from accidental changes.
37. A relationship is formed via that relates two tables where one table references
other table’s key.
a. Candidate Key (b) Primary Key (c) Foreign Key (d) Check Constraint
38. Which command is used to add new column in existing table?
Ans. ALTER TABLE
39. Which clause is used to search for NULL values in any column?
Ans. IS NULL
40. Which command is used to see information like name of columns, data type, size etc. ?
Ans. DESCRIBE OR DESC
41. Which clause is used for pattern matching? What are the 2 main characters used for matching the pattern?
(a) LIKE
(b) % (percent) and _ (underscore)
42. Which clause is used to see the output of query in ascending or descending order?
Ans. ORDER BY
43. Which clause is used to eliminate the duplicate rows from output?
Ans. DISTINCT
44. What is the minimum number of column required in MySQL to create table?
Ans. ONE (1)
45. Which command is used to remove the table from database?
Ans. DROP TABLE
46. Which command is used to add new record in table?
Ans. INSERT INTO
47. Which option of ORDER BY clause is used to arrange the output in descending order?
Ans. DESC
48. Which command is used to change the existing information of table?
Ans. UPDATE
49. BETWEEN clause in MySQL cannot be used for
a)Integer Fields b) Varchar fields c) Date Fields d) None of these
50. In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has degree 3 and
cardinality 5, what will be the degree and cardinality of the Cartesian product of Alpha and Beta?
a. 5,3 b. 8,15 c. 3,5 d. 15,8
50. Which of the following MySQL command/clause is used to sort the data in a table
a) SORT b) ASCENDING c) ORDER BY d) DROP
51. Table A has 3 rows and 4 columns and Table B has 5 rows and 6 columns. What isthe degree and
cardinality of Cartesian product of A and B?
Ans: Degree is 10 and Cardinality is 15
52. Which of the following is not an Aggregate function.
Ans: DISTINCT
53. Which SQL command is used to change some values in existing rows?
a) update b) insert c) alter d) order
54. In MYSQL database, if a table, Student has degree 2 and cardinality 3, and another table, Address has
degree 5 and cardinality 6, what will be the degree and cardinality of the Cartesian product of student and
address?
a. 6,18 b. 7,18 c. 10,9 d. 12,15
55. Which of the following keywords will you use in the following query to display the unique values of the
column dept_name?
SELECT dept_name FROM Company;
(a)All (b) key (c) Distinct (d) Name
56. Which of the following command is a DDL command?
(a) SELECT (b) GROUP BY (c) DROP (d) UNIQUE
57. Fill in the blank: Number of records/ tuples/ rows in a relation or table of a database is referred to as
(a) Domain (b) Degree (c) Cardinality (d) Integrity
58. The clause is used for pattern matching in MySQL queries.
(a) ALL (b) DESC (c) MATCH (d) LIKE
59. The SQL keyword is used to specify the table(s) that contains the data to be retrieved.
Ans:From

60. If column “salary” contains the data set (45000, 5000, 55000, 45000, 55000), what will be the output after the
execution of the given query?
SELECT AVG (DISTINCT salary) FROM employee;
(A) 38500 (B) 40000 (C) 41000 (D) 35000
61. The correct SQL from below to find the temperature in increasing order of all cities.
(A) SELECT city FROM weather order by temperature ;
(B) SELECT city, temperature FROM weather ;
(C) SELECT city, temperature FROM weather ORDER BY temperature ;
(D) SELECT city, temperature FROM weather ORDER BY city ;

You might also like