Database Questions and Answers – SQL Basics and SQL Data Definition

This set of Database Multiple Choice Questions & Answers (MCQs) focuses on “SQL Basics and SQL Data Definition”.

1. Which one of the following is used to define the structure of the relation, deleting relations and relating schemas?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer

Answer: b
Explanation: Data Definition language is the language which performs all the operation in defining structure of relation.

2. Which one of the following provides the ability to query information from the database and to insert tuples into, delete tuples from, and modify tuples in the database?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema
View Answer

Answer: a
Explanation: DML performs the change in the values of the relation.

3.

advertisement
advertisement
CREATE TABLE employee (name VARCHAR, id INTEGER)

What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer

Answer: b
Explanation: Data Definition language is the language which performs all the operation in defining structure of relation.

4.

SELECT * FROM employee

What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint
View Answer

Answer: a
Explanation: Select operation just shows the required fields of the relation. So it forms a DML.
advertisement

5. The basic data type char(n) is a _____ length character string and varchar(n) is _____ length character.
a) Fixed, equal
b) Equal, variable
c) Fixed, variable
d) Variable, equal
View Answer

Answer: c
Explanation: Varchar changes its length accordingly whereas char has a specific length which has to be filled by either letters or spaces.
advertisement

6. An attribute A of datatype varchar(20) has the value “Avi”. The attribute B of datatype char(20) has value ”Reed”. Here attribute A has ____ spaces and attribute B has ____ spaces.
a) 3, 20
b) 20, 4
c) 20, 20
d) 3, 4
View Answer

Answer: a
Explanation: Varchar changes its length accordingly whereas char has a specific length which has to be filled by either letters or spaces.

7. To remove a relation from an SQL database, we use the ______ command.
a) Delete
b) Purge
c) Remove
d) Drop table
View Answer

Answer: d
Explanation: Drop table deletes the whole structure of the relation .purge removes the table which cannot be obtained again.

8.

DELETE FROM r;   //r - relation

This command performs which of the following action?
a) Remove relation
b) Clear relation entries
c) Delete fields
d) Delete rows
View Answer

Answer: b
Explanation: Delete command removes the entries in the table.

9.

INSERT INTO instructor VALUES (10211, ’Smith’, ’Biology’, 66000);

What type of statement is this?
a) Query
b) DML
c) Relational
d) DDL
View Answer

Answer: b
Explanation: The values are manipulated. So it is a DML.

10. Updates that violate __________ are disallowed.
a) Integrity constraints
b) Transaction control
c) Authorization
d) DDL constraints
View Answer

Answer: a
Explanation: Integrity constraint has to be maintained in the entries of the relation.

Sanfoundry Global Education & Learning Series – Database Management System.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.