It’s strange to encounter a maintenance problem today:
Execute SQL statement insert into test.COLUMNS select * from information_ schema.COLUMNS ; error 1406 (22001): data too long, field len 30, data len 48
The background of the problem is like this:
1. Tidb4.0 distributed database system, de information_ schema.TABLES Copy a table structure as like as two peas, then build a blank table to a temporary library CSDN.
2. Execute insert into on the command line of tidb test.COLUMNS select * from information_ schema.COLUMNS ;
3. Try mysqldump from information_ If you export data from the tables table of the schema and import it into the tables table of the CSDN library, you will still report an error.
4. Two libraries information were checked_ Schema and CSDN libraries have the same table structure.
If there is an error, it should be that the field is only 30 long, but the entered data lacks 48 strings. Then check the table structure carefully
CREATE TABLE `TABLES` (
`TABLE_CATALOG` varchar(512) DEFAULT NULL,
`TABLE_SCHEMA` varchar(64) DEFAULT NULL,
`TABLE_NAME` varchar(64) DEFAULT NULL,
`COLUMN_NAME` varchar(64) DEFAULT NULL,
`ORDINAL_POSITION` bigint(64) DEFAULT NULL,
`COLUMN_DEFAULT` text DEFAULT NULL,
`IS_NULLABLE` varchar(3) DEFAULT NULL,
`DATA_TYPE` varchar(64) DEFAULT NULL,
`CHARACTER_MAXIMUM_LENGTH` bigint(21) DEFAULT NULL,
`CHARACTER_OCTET_LENGTH` bigint(21) DEFAULT NULL,
`NUMERIC_PRECISION` bigint(21) DEFAULT NULL,
`NUMERIC_SCALE` bigint(21) DEFAULT NULL,
`DATETIME_PRECISION` bigint(21) DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(32) DEFAULT NULL,
`COLLATION_NAME` varchar(32) DEFAULT NULL,
`COLUMN_TYPE` text DEFAULT NULL,
`COLUMN_KEY` varchar(3) DEFAULT NULL,
`EXTRA` varchar(30) DEFAULT NULL,
`PRIVILEGES` varchar(80) DEFAULT NULL,
`COLUMN_COMMENT` varchar(1024) DEFAULT NULL,
`GENERATION_EXPRESSION` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
If you see that a field extra is’ extra ‘varchar (30) default null, check whether the value of the data in this field exceeds the value.
mysql-17:31:41> select length(EXTRA) l,EXTRA from information_schema.TABLES order by l desc limit 50;
+----+--------------------------------------------------+
| l | EXTRA |
+----+--------------------------------------------------+
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
| 48 | DEFAULT_GENERATED on update CURRENT_TIMESTAMP(3) |
Check the length (extra). The maximum length is 48. Is that the reason for the character set?In a database like mysql, the character set is different and the space occupied is different.
First look at the character set of the library. It’s the same:
+----------+------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------+
| csdn | CREATE DATABASE `csdn` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+------------------------------------------------------------------+
+--------------------+--------------------------------------------------------------------------------+
| Database | Create Database |
+--------------------+--------------------------------------------------------------------------------+
| INFORMATION_SCHEMA | CREATE DATABASE `INFORMATION_SCHEMA` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+--------------------+--------------------------------------------------------------------------------+
Let’s look at the definition of character set in the following table again. Is it the same
use information_schema;
CREATE TABLE `TABLES` (
`TABLE_CATALOG` varchar(512) DEFAULT NULL,
`TABLE_SCHEMA` varchar(64) DEFAULT NULL,
`TABLE_NAME` varchar(64) DEFAULT NULL,
`COLUMN_NAME` varchar(64) DEFAULT NULL,
`ORDINAL_POSITION` bigint(64) DEFAULT NULL,
`COLUMN_DEFAULT` text DEFAULT NULL,
`IS_NULLABLE` varchar(3) DEFAULT NULL,
`DATA_TYPE` varchar(64) DEFAULT NULL,
`CHARACTER_MAXIMUM_LENGTH` bigint(21) DEFAULT NULL,
`CHARACTER_OCTET_LENGTH` bigint(21) DEFAULT NULL,
`NUMERIC_PRECISION` bigint(21) DEFAULT NULL,
`NUMERIC_SCALE` bigint(21) DEFAULT NULL,
`DATETIME_PRECISION` bigint(21) DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(32) DEFAULT NULL,
`COLLATION_NAME` varchar(32) DEFAULT NULL,
`COLUMN_TYPE` text DEFAULT NULL,
`COLUMN_KEY` varchar(3) DEFAULT NULL,
`EXTRA` varchar(30) DEFAULT NULL,
`PRIVILEGES` varchar(80) DEFAULT NULL,
`COLUMN_COMMENT` varchar(1024) DEFAULT NULL,
`GENERATION_EXPRESSION` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
use csdn;
CREATE TABLE `TABLES` (
`TABLE_CATALOG` varchar(512) DEFAULT NULL,
`TABLE_SCHEMA` varchar(64) DEFAULT NULL,
`TABLE_NAME` varchar(64) DEFAULT NULL,
`COLUMN_NAME` varchar(64) DEFAULT NULL,
`ORDINAL_POSITION` bigint(64) DEFAULT NULL,
`COLUMN_DEFAULT` text DEFAULT NULL,
`IS_NULLABLE` varchar(3) DEFAULT NULL,
`DATA_TYPE` varchar(64) DEFAULT NULL,
`CHARACTER_MAXIMUM_LENGTH` bigint(21) DEFAULT NULL,
`CHARACTER_OCTET_LENGTH` bigint(21) DEFAULT NULL,
`NUMERIC_PRECISION` bigint(21) DEFAULT NULL,
`NUMERIC_SCALE` bigint(21) DEFAULT NULL,
`DATETIME_PRECISION` bigint(21) DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(32) DEFAULT NULL,
`COLLATION_NAME` varchar(32) DEFAULT NULL,
`COLUMN_TYPE` text DEFAULT NULL,
`COLUMN_KEY` varchar(3) DEFAULT NULL,
`EXTRA` varchar(30) DEFAULT NULL,
`PRIVILEGES` varchar(80) DEFAULT NULL,
`COLUMN_COMMENT` varchar(1024) DEFAULT NULL,
`GENERATION_EXPRESSION` text NOT NULL,
KEY `idx_pri` (`TABLE_SCHEMA`,`TABLE_NAME`,`COLUMN_KEY`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
Of course, the solution is very simple, which is to modify the character length in the tables table of CSDN library
alter table csdn.TABLES modify `EXTRA` varchar(128) DEFAULT NULL;
But why information_ In the tables table of the schema library, why can 48 characters be accessed in ‘extra’ varchar (30) default null?This problem is worthy of further study.
Read More:
- circuit_breaking_exception,“reason“:“[parent] Data too large, data for [<http_request>]
- TypeError: object of type ‘Cursor‘ has no len()
- Must have equal len keys and value when setting with an Iterable
- Typeerror: object of type ‘response’ has no len() why?
- TypeError: object of type ‘builtin_function_or_method’ has no len()
- Inconsistency between adapter data and UI data after dragging recyclerview (data disorder)
- IIS “Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long.”
- SSIS Exception: Failed to retrieve long data for column “TS_Description”
- Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long
- Kibana access error: data too large [How to Solve]
- No data: data: get host by name failed in TCP_ Connect() error resolution
- Django + jQuery get data in the form + Ajax send data
- Failed to load response data:No data found for resource with given identifie
- [MySQL] [serialize] [error record] after modifying data, no data will be returned (in fact, MySQL does not support it)
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data
- Syntax error or access violation: 1071 specified key was too long; max key length is 767 bytes
- This (code, message, data: null) still exists after importing spring cloud project into Lombok; the data in the project is unrecognized
- DM database data migration DTS error solution
- Java long type error: error: integer number too large