RDBMS Questions and Answers – SQL Data definition

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

1. Which of the following information does an SQL DDL not specify?
a) The schema for each relation
b) The integrity constraints
c) The operations on the tuples
d) The security and authorization information for each relation
View Answer

Answer: c
Explanation: The SQL DDL does not specify the operations that are supposed to be made on the tuples. DDL means Data definition language, hence it does not include the operations made.

2. Which of the following data types does the SQL standard not support?
a) char(n)
b) String(n)
c) varchar(n)
d) float(n)
View Answer

Answer: b
Explanation: The SQL standard does not support String(n) but it supports char, varchar and float.

3. Which command is used to create a new relation in SQL
a) create table( , …)
b) create relation( , …)
c) new table( , …)
d) new relation( , …)
View Answer

Answer: a
Explanation: We use the create table command to create a new relation in the database. The syntax is
create table( , …);
advertisement
advertisement

4. If a1, a2, a3 are attributes in a relation and S is another relation, which of the following is an incorrect specification of an integrity constraint?
a) primary key(a1, a2, a3)
b) primary key(a1)
c) foreign key(a1, a2) references S
d) foreign key(a1, a2)
View Answer

Answer: d
Explanation: Whenever the integrity constraint foreign key is mentioned, the attributes that are the foreign keys should always be referenced from the relation in which they are primary keys.

5. What is the syntax to load data into the database? (Consider D as the database and a, b, c as data)
a) enter into D (a, b, c);
b) insert into D values (a, b, c);
c) insert into D (a, b, c);
d) insert (a, b, c) values into D;
View Answer

Answer: b
Explanation: To load data into a database we use the insert into command. The syntax is
insert into D values (a, b, c) where a, b, c are the appropriate values

6. Which of the following commands do we use to delete a relation (R) from a database?
a) drop table R
b) drop relation R
c) delete table R
d) delete from R
View Answer

Answer: a
Explanation: The drop table command is used to delete a relation from a database whereas the delete table removes all the tuples from a relation

7. Which of the following commands do we use to delete all the tuples from a relation (R)?
a) delete table R
b) drop table R
c) delete from R
d) drop from R
View Answer

Answer: c
Explanation: The delete from command is used to delete all the tuples in a relation. The drop table totally deletes a relation.
advertisement

8. Choose the correct command to delete an attribute A from a relation R
a) alter table R delete A
b) alter table R drop A
c) alter table drop A from R
d) delete A from R
View Answer

Answer: b
Explanation: We can delete an attribute from a relation using the alter table command with the following syntax
alter table drop

9. create table apartment(ownerID varchar (5), ownername varchar(25), floor numeric(4,0), primary key (ownerID));
Choose the correct option regarding the above statement
a) The statement is syntactically wrong
b) It creates a relation with three attributes ownerID, ownername, floor in which floor cannot be null.
c) It creates a relation with three attributes ownerID, ownername, floor in which ownerID cannot be null.
d) It creates a relation with three attributes ownerID, ownername, floor in which ownername must consist of at least 25 characters.
View Answer

Answer: c
Explanation: It creates a relation apartment with three attributes as specified. The attribute ownername cannot be null because it is the primary key of the relation.
advertisement

10. What does the notnull integrity constraint do?
a) It ensures that at least one tuple is present in the relation
b) It ensures that at least one foreign key is present in the relation
c) It ensures that all tuples have a finite value on a specified attribute
d) It ensures that all tuples have finite attributes on all the relations
View Answer

Answer: c
Explanation: The notnull integrity constraint ensures that all the tuples have a finite value on the specified attribute in the relation. It avoids the specification of null values.

Sanfoundry Global Education & Learning Series – RDBMS.

To practice all areas of RDBMS, here is complete set of 1000+ Multiple Choice Questions and Answers.

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.