0 votes
1 view
in SQL by (36.2k points)

Can anyone tell me how to change the column name in SQL?

1 Answer

0 votes
by (87.5k points)

In MySQL, here is the syntax to rename the column:

ALTER TABLE table_name

change column1 column2 data type;

In Oracle, here is the syntax to rename the column:

ALTER TABLE table_name

RENAME COLUMN column1 to column2;

In MS SQL, we cannot use Alter table statement to change the column name. We use sp_rename to change the column name and here is the syntax to rename the column:

sp_rename ‘previous_table_name’, ‘new_table_name’;

If you want to learn SQL, you can enroll for this SQL course program by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Apr 26 in SQL by Sudhir_1997 (36.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...