How can we change the name of a column of a table?

Answers were Sorted based on User's Feedback



How can we change the name of a column of a table?..

Answer / vipul dalwala

ALTER TABLE table_name change OLD_COLUMN_NAME
NEW_COLUMN_NAME VARCHCHAR(100) NULL;

Is This Answer Correct ?    18 Yes 3 No

How can we change the name of a column of a table?..

Answer / tushar

ALTER TABLE table_name change OLD_COLUMN_NAME
NEW_COLUMN_NAME VARCHAR(255) NULL;

Is This Answer Correct ?    6 Yes 0 No

How can we change the name of a column of a table?..

Answer / nithya

changing a column name differs from the type of database we use.

MySQL:
ALTER table customer CHANGE Address Addr char(50);

Oracle:
ALTER table customer RENAME COLUMN Address TO Addr;

SQL Server:
It is not possible to rename a column using the ALTER TABLE
statement in SQL Server. Use sp_rename instead.

Is This Answer Correct ?    3 Yes 0 No

How can we change the name of a column of a table?..

Answer / shweth

we can use ALIAS function for this
select tree AS plant
from table;
or simply we can skip writing AS but shoudnt write a comma
between the old and new column names.

Is This Answer Correct ?    5 Yes 4 No

How can we change the name of a column of a table?..

Answer / owais masood

RENAME cannot be used to change the column name, however, it
is used to change the table or database name. However the
CHANGE is used to to rename a column with the su=yntax given
above by vipul (Answer 2)

Is This Answer Correct ?    1 Yes 0 No

How can we change the name of a column of a table?..

Answer / chandrakant agrawal

ALTER TABLE <owner_name.tab_name> RENAME COLUMN <old_name>
TO <new_name>;


We can also modify the datatype,size of the column using
command alter table

Is This Answer Correct ?    1 Yes 6 No

How can we change the name of a column of a table?..

Answer / chaithra.t

ALTER TABLE tablename RENAME COLUMN old_columnname TO
new_columnname;

above is to change the column name of the table.
In case if u want to change the table name then:

ALTER TABLE tablename RENAME TO new_tablename;

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More MySQL Interview Questions

What is mysql good for?

0 Answers  


What does mysql flush tables do?

0 Answers  


How you will show all data from a table.

0 Answers  


In which language mysql has been written?

0 Answers  


How do I rename a procedure?

0 Answers  






How many sql dml commands are supported by 'mysql'?

0 Answers  


How to use triggers to track changes in mysql?

0 Answers  


What is the use of mysqli_fetch_assoc?

0 Answers  


What is pdo :: fetch_assoc?

0 Answers  


How to increment dates by 1 in mysql?

0 Answers  


What is timestamp in mysql?

0 Answers  


What data structure does mysql use?

0 Answers  


Categories