Skip to main contentSkip to solution

Rohan created a table 'Product' with structure: PID, Pname, Pdescp, Pqty, Pprice

He added 10 records in the table. Now he wants to change the size of column 'Pname' from 20 to 25.

Identify the correct SQL query to do this.

Solution

✅ Correct Option: 3

ALTER TABLE with MODIFY changes the data type or size of an existing column, keeping its name. So ALTER TABLE PRODUCT MODIFY PNAME VARCHAR(25); changes the size of Pname from 20 to 25 and keeps the 10 existing records.


Option 1: ADD inserts a new column. Pname already exists, so this gives an error.

Option 2: UPDATE changes the data in rows (as in UPDATE ... SET). It is not an ALTER TABLE clause.

Option 4: CHANGE is a real clause, but it renames a column and needs both the old and new names (CHANGE old_name new_name datatype). With only one name, the query is incomplete.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question