Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql table name length limit? - please test on default mysql (asked in 2010 for mysql <5.5)

Tags:

sql

mysql

Does vanilla MySQL have a table name length limit?

(I've tested to 100 chrs on my modified MySQL - no limit so far.. I don't have vanilla MySQL accessible readily, though, but I wonder if my dynamically-created table schema will run on default MySQL)

  • Question: What happens if you go over 64 chrs on default MySQL? Can you test this please and paste MySQL error or results if any?

  • n.b. usage scenario where per user would never select another user's dataset.

like image 492
ina Avatar asked Aug 15 '10 09:08

ina


People also ask

What is the maximum length of a table name in MySQL?

18, NDB Cluster imposed a maximum length of 63 characters for names of databases and tables. As of NDB 8.0.

Which is the maximum length of a table name?

The maximum length of a table name is 64 characters long according to MySQl version 8.0.

How do I find the length of a table in MySQL?

This can be accomplished easily with the following query: SELECT TABLE_SCHEMA AS `Database`, TABLE_NAME AS `Table`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)` FROM information_schema.

How long should SQL table names be?

Table names must follow the rules for SQL Server identifiers, and be less than 128 characters.


2 Answers

Here're the limits

Database: 64 
Table: 64 
Column: 64 
Index: 64 
Constraint: 64 
Stored Function or Procedure: 64 
Trigger: 64 
View: 64 
Compound Statement Label: 16

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

like image 94
hgulyan Avatar answered Oct 04 '22 01:10

hgulyan


The question is based on wrong assumptions.
There shouldn't be a direct answer.
It is duty of every fellow SOer to warn the OP against wrong decision. Instead of helping him wrong way to get your rep points.

Always avoid dynamically-created table schemas. Database schema is not the thing that should be dynamic. The data in the tables - yes. but not tables itself

Note that you are using a relational database. And while it is as simple as an egg to make a relation based on the field value, at the same time it's impossible based on table names.
Therefore, there shouldn't be dynamically created tables and data splitting. Use one table for similar data. That's one of most basic database rules.

like image 23
Your Common Sense Avatar answered Oct 04 '22 01:10

Your Common Sense