Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Column Name in MySQL [duplicate]

Tags:

sql

mysql

After searching I can't figure out what I need to do in ALTER TABLE genres to change the col id to genre_id any ideas?

like image 419
Johnny Avatar asked Nov 19 '10 11:11

Johnny


People also ask

How do I rename a column in MySQL?

To rename a column in MySQL the following syntax is used: ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name; This command is used to change the name of a column to a new column name.

What is duplicate column name MySQL?

September 30, 2019. This typically happens when you retrieve data from multiple tables with the same column name using a JOIN statement. You might receive an error like this: ERROR: Column 'col_name' in field list is ambiguous.

How do you rename a column name?

1. Renaming a column name using the ALTER keyword. Line 2: RENAME COLUMN OldColumnName TO NewColumnName; For Example: Write a query to rename the column name “SID” to “StudentsID”.


1 Answers

alter table genres change id genre_id int(10) auto_increment;
like image 88
XMen Avatar answered Sep 20 '22 06:09

XMen