-1

I'm learning the basics of MySQL using Python. When creating tables, they will always be named without any formatting, and ignore formatting I use in the script. How can I adjust my code to add a capital when creating a table? Sorry if this is quite basic, my current knowledge means its hard for me to use the answers of relevant questions such as this.

My query:

SQL_Create_Table = """ CREATE TABLE Employee """
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Laurie
  • 1,189
  • 1
  • 12
  • 28
  • 3
    Trying to make table names case-sensitive is usually not a good idea; or generally worth-while.See [this](https://stackoverflow.com/questions/6134006/are-table-names-in-mysql-case-sensitive) – Uueerdo Sep 11 '18 at 19:18
  • Understood, I wont worry about formatting such as this. I would still be interested in seeing an answer however. – Laurie Sep 11 '18 at 19:19
  • 1
    Are you using Windows? MySQL saves table names as lower case by default on Windows so you could (but shouldn't) edit [lower_case_table_names](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lower_case_table_names). – Daniel Ong Sep 11 '18 at 19:20
  • Yes Windows 10 64-bit, do you know how this can be changed? – Laurie Sep 11 '18 at 19:20
  • 1
    @LaurieBamber the entry I linked covers the topic fairly thoroughly... as far as I know it cannot be changed on a Windows system at all. – Uueerdo Sep 11 '18 at 19:21
  • Perfect, thanks for the help guys. – Laurie Sep 11 '18 at 19:21
  • Also, that link you just added in has no relevance; it is about changing the case of the contents of the field, not the name of the field. – Uueerdo Sep 11 '18 at 19:22

1 Answers1

1

From MySQL's docs:

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names.

Therefore, on Windows, tables names aren't case sensitive by default, while on most Unix / Linux distributions, they will be case sensitive.

If you want to modify the default behavior, you can modify this configuration in my.cnf / my.ini: lower_case_table_names

More information about this configuration key here.

Tomer Shay
  • 771
  • 6
  • 17
  • The docs explicitly say "You should not set lower_case_table_names to 0 if you are running MySQL on a system where the data directory resides on a case-insensitive file system (such as on Windows or macOS)" – Daniel Ong Sep 11 '18 at 19:25
  • Yep, thanks for the help but will just move forward without caring about the formatting. – Laurie Sep 11 '18 at 19:26