ExamVeda
Login
Home
This question belongs to MySQL MySQL Miscellaneous
MySQL Miscellaneous
?

Find out the logical error in the following MySQL code snippet?
CREATE TABLE person
( person_id VARCHAR(20),
 Name VARCHAR (20),
 Address VARCHAR (20),
 Mobile_no  SMALLINT 
);

Answer & Solution
Correct Answer: Option C
This code snippet is trying to create a table named "person" with four columns:

* person_id (a text field of length 20 characters)
* Name (a text field of length 20 characters)
* Address (a text field of length 20 characters)
* Mobile_no (a small integer)

The problem is with the Mobile_no column. Mobile phone numbers are typically too long for a SMALLINT data type.

A SMALLINT can hold a maximum value of 32,767. This is not enough to store a typical mobile number.

The correct way to define this column would be using VARCHAR for the mobile number, as it is a text field.

Therefore, the logical error in the code snippet is "Incorrect definition" (Option B).
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.