Skip to main contentSkip to solution

To update the datatype of an attribute in a table, which of the following syntax will be used?

Solution

✅ Correct Option: 1

ALTER TABLE with MODIFY changes the definition of an existing column, including its datatype. For example, ALTER TABLE student MODIFY marks FLOAT;\texttt{ALTER TABLE student MODIFY marks FLOAT;} changes the datatype of marks to FLOAT.


Option 2: ADD inserts a new column into the table. It does not change an existing one.

Options 3 and 4: UPDATE and SET belong to the DML statement UPDATE ... SET\texttt{UPDATE ... SET}, which changes row values (data), not the table structure. They are not valid clauses of ALTER TABLE.

In MySQL and Oracle the clause is MODIFY, while SQL Server uses ALTER COLUMN.

Keyboard Shortcuts

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