Home  >  Article  >  Database  >  How to set the table name in mysql under Linux?

How to set the table name in mysql under Linux?

青灯夜游
青灯夜游Original
2020-10-22 10:00:282524browse

Mysql under Linux can modify the table name through the "ALTER TABLE old table name RENAME [TO] new table name;" statement; you can also configure the my.cnf file and modify the value of the "lower_case_table_names" option to " 1" to set the table name to be case-insensitive.

How to set the table name in mysql under Linux?

(Recommended tutorial: mysql video tutorial)

mysql setting table name under Linux

In MySQL, you can use the ALTER TABLE statement to modify the table name.

You can use the ALTER TABLE statement in MySQL to change the structure of the original table, such as adding or deleting columns, changing the original column type, renaming columns or tables, etc.

The syntax rules are as follows:

ALTER TABLE <旧表名> RENAME [TO] <新表名>;

Among them, TO is an optional parameter, and whether it is used or not does not affect the result.

Example

Use ALTER TABLE to rename the data table student to tb_students_info. The SQL statement and running results are as follows.

mysql> ALTER TABLE student RENAME TO tb_students_info;
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_test   |
+------------------+
| tb_students_info |
+------------------+
1 row in set (0.00 sec)

Tip: Modifying the table name does not modify the structure of the table, so the structure of the table after the name is modified is the same as that of the table before the name was modified. Users can use the DESC command to view the modified table structure.

MySQL under Linux sets the table name to be case-insensitive

MySQL under Linux The default is case-sensitive table names

Through the following settings, you can make MySQL not case-sensitive table names:

1. Log in as root and modify /{mysql installation path} /etc/my.cnf

2. Under the [mysqld] node, add a line: lower_case_table_names=1

3. Restart MySQL.

/bin/systemctl restart mysql.service

The above is the detailed content of How to set the table name in mysql under Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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