The operating system has certain restrictions on MySQL table naming. Let's take a look at the operating system's restrictions on MySQL database and MySQL table naming, I hope this will help you learn about MySQL table naming.
MySQL has a naming rule for databases and MySQL tables:
- The name can be composed of any letter or number character in the current character set, and the underline and dollar sign can also be $.
- The name cannot exceed 64 characters.
However, because the names of databases and tables correspond to directories and file names, the operating system running on the server may impose additional restrictions.
First, the database and table names are limited to characters that are valid for the file name. For example, $ is allowed in MySQL principles. However, if your operating system does not allow this, you cannot use it in a directory or table name. In fact, this is not a concern for Unix or Windows. The biggest difficulty is to directly reference the name in the shell when executing database management. For example, if you name a database such as running $ my_db, contains a dollar sign. Any reference to the name from the shell may be interpreted by shell as a reference to a variable:
% Ls success $ my_db
My_db: undefined variable
To do this, you must escape the escape $ character or use quotation marks to disable its special meaning:
% Ls \ tables $ my_db
% Ls 'tables $ my_db'
If you use quotation marks, you must use single quotation marks, but double quotation marks do not prohibit variable interpretation.
Secondly, although MySQL allows the database and table names to be up to 64 characters long, the name length is limited by the length limited by your operating system, this is not a problem, though the old System V forces 14 characters ). In this case, your database name can contain up to 14 characters, and the table name can contain up to 10 characters, because the table file name has a dot .) and a three-character extension.
Third, the Case sensitivity of the file system affects how you name and reference databases and table names. If the file system is case sensitive such as Unix), the two names my_tbl and MY_TBL are different tables. If the file system is not case sensitive, such as Windows), the two names indicate the same table. If you use a Unix server to develop a database, and you may transfer it to Windows, remember this.
Introduction to modifying table structure statements in MySQL
Use ALTER to modify the table structure in MYSQL
Use the MySQL command line to change the password
Location of MySQL DATA DIRECTORY
Optimize MySQL statement instances through Indexes