Home > Database > Mysql Tutorial > body text

How to modify field name in mysql

王林
Release: 2020-09-29 15:25:12
Original
10870 people have browsed it

Mysql method to modify field names: [ALTER TABLE table name CHANGE[column] old field name new field name new data type;]. If you want to modify the table name, you can execute the [ALTER TABLE old table name RENAME TO new table name;] statement.

How to modify field name in mysql

mysql Modify field name:

(Recommended tutorial: mysql tutorial)

ALTER  TABLE 表名 CHANGE [column] 旧字段名 新字段名 新数据类型;
mysql> alter table white_user change column name nick_name  varchar(50) null comment '昵称'; -- 正确
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0
Copy after login

mysql Modify table name

ALTER TABLE 旧表名 RENAME TO 新表名 ;
 
mysql> show tables ;
+-------------------+
| Tables_in_db_test |
+-------------------+
| white_user   |
+-------------------+
1 row in set (0.00 sec)
 
mysql> alter table white_user rename to white_user_new ;
Query OK, 0 rows affected (0.00 sec)
 
mysql> show tables ;
+-------------------+
| Tables_in_db_test |
+-------------------+
| white_user_new    |
+-------------------+
1 row in set (0.00 sec)
Copy after login

Related recommendations:php training

The above is the detailed content of How to modify field name in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template