Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 28 of 58
Marks: +1, -0
(I) (a) Write any one difference between CHAR and VARCHAR data types in MySQL.
OR
(b) Write one difference between Primary key and Unique constraint.
(II) (a) Write an SQL command to remove a column named ADDRESS, from a table named CUSTOMER.
OR
(b) Write an SQL command to add a column named ADDRESS, of type VARCHAR(20) in a table named CUSTOMER.
[CBSE 2025 Compartment]
Solution:  
(I)(a)
CHAR(n)VARCHAR(n)
Fixed-length data type: always uses n characters of storage; shorter values are padded with spaces.Variable-length data type: uses only as much storage as the actual value (up to n characters).
OR (I)(b)
PRIMARY KEYUNIQUE
Does not allow NULL values in the column.Allows NULL values in the column.
Only one primary key per table.A table can have many UNIQUE columns.
(II)(a)
ALTER TABLE CUSTOMER DROP COLUMN ADDRESS;
OR (II)(b)
ALTER TABLE CUSTOMER ADD COLUMN ADDRESS VARCHAR(20);
The keyword COLUMN is optional in both commands.
© examsnet.com
Advertisements
Go to Question: