250+ TOP MCQs on SQL Data definition and Answers

RDBMS Multiple Choice Questions 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

Answer: c
Clarification: 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)

Answer: b
Clarification: 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
Clarification: We use the create table command to create a new relation in the database. The syntax is
create table(, …);

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)

Answer: d
Clarification: 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;

Answer: b
Clarification: 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

Answer: a
Clarification: 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

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

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

Answer: b
Clarification: 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.

Answer: c
Clarification: 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.

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

Answer: c
Clarification: 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.

Leave a Reply

Your email address will not be published. Required fields are marked *