Test Index
CBSE Class 12 Computer Science 2025 Paper Compartment
© examsnet.com
Question : 27 of 37
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.
Solution:
(I)(a)
OR (I)(b)
(II)(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). |
| PRIMARY KEY | UNIQUE |
|---|---|
| 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. |
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
Go to Question: