
How to Rename column name in MySql ?
To rename a column in a MySQL table, you can use the ALTER TABLE statement along with the RENAME keyword.
Raname column name of MySQL table
Query :
ALTER TABLE tags RENAME COLUMN title TO name;
The SQL statement ALTER TABLE tags RENAME COLUMN title TO name;
is used to rename a column named title to name in the tags table.
Here's a breakdown of the statement:
ALTER TABLE tags
: Specifies the table tags that you want to modify.
RENAME COLUMN
: Indicates that you want to rename a column.
title
: Specifies the current name of the column that you want to rename.
TO name
: Specifies the new name that you want to assign to the column.
Create table statement for the tags table. You can use alter command after creating the tags table in your mysql database.
CREATE TABLE `tags` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Sql
- Get number of connections being used by a specific user in MySQL
- How to get the list of all constraints in MySQL database
- How to check the MySQL version
- How to get yesterday's date in MySQL ?
- How to create function in MySQL ?
- Clear the terminal screen in MySQL within the Windows powershell
- How to show database tables in mysql using command line
- How to create a new table from existing table in SQL
- How to create view in MySQL database
- ERROR 3780 (HY000): Referencing column 'order_id' and referenced column 'id' in foreign key constraint 'order_items_ibfk_1' are incompatible.
- Get full name of a person in SQL using function
- How to check column exists or not in table using MySQL
- Check constraint in MySQL
- SQL query to delete all rows older than 30 days
- Database connection using mySQLi with object-oriented
- Change existing MySQL table column id to autoincrement
- Cannot drop index 'fk_role_id': needed in a foreign key constraint
- Self join in mysql employee manager example
- Get data in random order with limit from table using mysql
- Insert multiple rows in a single MySQL query
- How to retrieve data from two tables with one SQL statement
- 1553 Cannot drop index 'posts_user_id_foreign': needed in a foreign key constraint
- Drop foreign id column (user_id) in MySQL
- Get comma separated ids from table using MySQL
- SQLSTATE[01000]: Warning: 1265 Data truncated for column 'visibility' at row 1