Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Preliminary Verification and error Correction of some limit values in MySQL

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report