Examveda

How many of the following attributes are allowed only for numeric types?
UNSIGNED, ZEROFILL, CHARACTER SET, COLLATE

A. 1

B. 2

C. 3

D. 4

Answer: Option B

Solution (By Examveda Team)

This question is asking about special features in MySQL that can be applied to different data types. Let's break it down:
Data Types: Data types tell MySQL what kind of information you're storing. For example, "INT" is for whole numbers, "VARCHAR" is for text, and "DECIMAL" is for numbers with decimal points.
Attributes: These are like extra settings that modify the way data is stored.
The Question:
We need to identify which attributes are ONLY used with numeric data types (like INT, DECIMAL).
Let's look at the attributes:
UNSIGNED: This attribute prevents a numeric column from storing negative values. This is specifically for numbers. (This is allowed only for numeric types)
ZEROFILL: This attribute automatically pads numbers with zeros to the left if they are shorter than the column's defined length. This is also specifically for numbers. (This is allowed only for numeric types)
CHARACTER SET: This attribute defines which character encoding is used for storing text data. This is for text (like VARCHAR) and has nothing to do with numbers.
COLLATE: This attribute defines how text data is sorted and compared. Again, this is for text and not numbers.
The Answer:
Only UNSIGNED and ZEROFILL are allowed for numeric data types. So the answer is Option B: 2.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous