SQL Questions and Answers – SQL Data Types

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

1. What is the maximum value that can be stored in the datatype DECIMAL (5,2)?
a) 9999999
b) 99.99999
c) 999.99
d) 99999.99
View Answer

Answer: c
Explanation: In SQL, DECIMAL is a datatype that is used to store decimal values. In above question DECIMAL (5,2) means it can store a value having total 5 digits including 2 digits after decimal.

2. Which of the following command can be used to create a user defined datatype in SQL?
a) CREATE DATA
b) CREATE TYPE
c) CREATE DATATYPE
d) CREATE DATA TYPE
View Answer

Answer: b
Explanation: In SQL, the CREATE TYPE command can be used to create new user defined datatypes. It can be used as –

CREATE TYPE Currency AS DECIMAL (8,4);

3. Which of the following datatype is used to display a combination of date and time information?
a) DATETIME
b) DATE
c) TIME
d) TIMESTAMP
View Answer

Answer: a
Explanation: In SQL, the DATETIME datatype is used to display a combination of both date and time. It displays the value in YYYY-MM-DD hh:mm:ss format.
advertisement
advertisement

4. In SQL, which of the following datatypes has a maximum length of 255 characters?
a) TEXT
b) TINYTEXT
c) SMALLTEXT
d) CHAR
View Answer

Answer: b
Explanation: A TINYTEXT column has a maximum length of 255 characters. Each TINYTEXT value is stored using a one-byte length prefix that indicates the number of bytes in the value.

5. In SQL, if a value is entered in CHAR datatype which does not occupy all the length spaces then the remaining spaces will be occupied with blank spaces.
a) True
b) False
View Answer

Answer: a
Explanation: If a value is entered in the CHAR datatype which does not takes up the whole space then instead of changing the space of the datatype or removing the left space, they are filled by blank spaces.

6. Which of the following datatype is used for storing a maximum of one element from a predefined list consisting a maximum of 65535 elements?
a) STORE
b) LIST
c) SET
d) ENUM
View Answer

Answer: d
Explanation: Enum is used for compact data storage where the column may have a limited specified value. Here, the string values are automatically used as a numeric index. It can accept many datatypes like int, char, string etc.
advertisement

7. What is the default size of n in a column that has the datatype VARCHAR(n)?
a) 0
b) NULL
c) 1
d) Size of value entered
View Answer

Answer: c
Explanation: In SQL, the VARCHAR datatype is used to accept character values. Here, n issued to specify the size of the element that has the datatype VARCHAR. If any value is not specified then by default n is taken as 1.

8. Which of the following will be the most suitable data type for the given column?

advertisement
COLUMN Name: Id, Description: Nine-digit roll NUMBER starting WITH R, Example: R100218066

a) Integer
b) VARCHAR2(10)
c) CHAR (10)
d) Number (10)
View Answer

Answer: b
Explanation: The datatype VARCHAR2(10) will be the most suitable for the given column. VARCHAR is used because the ID is a combination of both numbers and letters. 10 specifies the maximum length of the ID that can be stored.

9. Which of the following will be the most suitable datatype for the given column?

COLUMN Name: Student_Photo, Description: Image OF every student

a) CLOB
b) VARCHAR
c) BLOB
d) PICTURE
View Answer

Answer: c
Explanation: In SQL, the BLOB datatype is used to binary large object that can hold a variable amount of data. It can also be used to hold pictures.

10. Which of the following will be the most suitable datatype for the given column?

COLUMN Name: Contact_Number, Description: Telephone NUMBER OF every student

a) NUMBER (10)
b) VARCHAR (10)
c) DECIMAL (10)
d) INTEGER
View Answer

Answer: a
Explanation: The datatype NUMBER (10) will be the most suitable for the given column. NUMBER is used because the contact number only contain numbers. 10 specifies the maximum length of the contact that can be stored.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, 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.