Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of setting Table name by mysql under Linux

Shulou Source: shulou.com Published: 2022-06-01 02:19:22 11月05日 Update

How to set the table name by mysql under Linux? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

Under Linux, mysql 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 to change the value of the "lower_case_table_names" option to "1" to set the table name to be case-insensitive.

(recommended tutorial: mysql video tutorial)

Set the table name of mysql under Linux

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

In MySQL, you can use ALTER TABLE statements to change the structure of the original table, such as adding or deleting columns, changing the original column type, renaming columns or tables, and so on.

The grammar 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 datasheet student to the tb_students_info,SQL statement and run the result as shown below.

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: changing the table name does not change the structure of the table, so the structure of the table after the name change is the same as that before the name change. Users can use the DESC command to view the modified table structure

Mysql setting table names under Linux are not case-sensitive

MySQL under Linux is case-sensitive by default.

You can make MySQL insensitive to table name case by setting as follows:

1. Log in with 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 Thank you for your reading! After reading the above, do you have a general understanding of the method of setting table names in mysql under Linux? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Tags: Content size structure statements methods can be passed by name tutorial article result question same one line parameter command data datasheet file more user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux MySQL OPPO Reno Shulou Tech Info