Vidyalelo
MySQL · Q1024

MySQL

Programming · MySQL · question 1024

Q1024

Which among the following is the correct syntax for defining "ENUM" in Mysql?

A.
gender ENUM ('M', 'F'),
Answer
B.
gender ENUM,
C.
gender ENUM ( ),
D.
none of the mentioned

Answer: Option A

Solution

Answer: Option A
Solution:
This question is about ENUM in MySQL, which is a special data type used to define a column that can only hold a specific set of values. Imagine you have a column called "gender," and you only want it to contain either "Male" or "Female." This is where ENUM comes in handy. Here's the breakdown of the options: * Option A: gender ENUM ('M', 'F')
This is the correct syntax. It defines a column named "gender" as an ENUM type, and it allows only two values: 'M' and 'F'. * Option B: gender ENUM
This is incorrect. It's missing the values within the parentheses. You need to specify the allowed values for your ENUM column. * Option C: gender ENUM ( )
This is also incorrect. The parentheses should contain the specific values you want to allow. * Option D: none of the mentioned
This is incorrect because Option A is the correct syntax. Therefore, the correct answer is Option A.