Get the App
SLTechnology News&Howtos  ›  Database  › 

Preliminary Verification and error Correction of some limit values in MySQL

Shulou Source: shulou.com Published: 2022-06-01 05:15:53 09月18日 Update

After coming back from the Pearl River in the evening, I saw an article saying that there are several limits for MySQL, and there are at most 1017 fields in a table. I doubt it after reading it. How to quickly verify it? it was already 11:00 when I saw the article, and I only had less than an hour to verify it. I think it can not be done by hand, write a simple script, can achieve the function.

So I wrote the following simple shelll script, running a loop to generate table structure information in batches.

The first thing I try is the int data type, and the script is as follows:

New=$1

Echo 'drop table if exists test_new;' > aaa.sql

Echo 'create table test_new (' > > aaa.sql)

Echo 'col1 int' > > aaa.sql

For ((item2witi > aaa.sql)

Echo'> aaa.sql

Mysql test aaa.sql

Echo 'create table test_new (' > > aaa.sql)

Echo 'col1 varchar (20)' > > aaa.sql

For ((item2witi > aaa.sql)

Echo'> aaa.sql

Mysql test 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.

+-+

| | Tables_in_test |

+-+

| | test |

| | test_data |

+-+

Obviously, it can be fully confirmed that the above conclusions are not rigorous enough, and as for the reasons for the details, we can go further and continue to analyze them later.

Similarly, we can simulate the maximum length of the following table name in 2 minutes. We know that the maximum length specified in MySQL is 64, and we can use lpad to achieve it.

Generates a 64-bit table name.

Mysql > select lpad ('axiomagen64')

+-+

| | lpad ('axiomager64') | |

+-+

| | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |

+-+

1 row in set (0.00 sec)

Mysql > create table aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (id int)

Query OK, 0 rows affected (0.09 sec)

You don't have to iterate, you just need to add a.

Mysql > create table aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (id int)

ERROR 1059 (42000): Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long

Tags: Fields scripts attempts maximum boundary faceted validation only time type length test generation iteration limit limit no rigorous divide into two and so on Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB OPPO Reno Shulou Technology vpn