Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 使用 playground v7.2.0 启动集群,往表插入数据报Field ‘id’ doesn’t have a default value错误

[TiDB Usage Environment] Development environment (TiDB is running in Ubuntu 22.04.2 LTS x86_64 (Py3.7.8) environment)
[TiDB Version] v7.2.0
[Operation]
- Below is the operation to export data from version v7.1.0
The exported file is my_db.sql, as shown below
my_db.sql (2.5 KB)
My SQL statement for creating the table is as follows. Why does the CREATE statement in the exported SQL file look like this according to the above export process?
CREATE TABLE `system` (
`id` bigint(20) AUTO_RANDOM NOT NULL COMMENT 'id',
`name` varchar(100) NOT NULL COMMENT 'system name',
`code` varchar(50) NOT NULL COMMENT 'system identifier',
`url` varchar(240) DEFAULT NULL COMMENT 'pc website',
`wap_url` varchar(240) DEFAULT NULL COMMENT 'mobile website',
`description` varchar(200) DEFAULT NULL COMMENT 'system description',
`status` smallint(6) NOT NULL COMMENT 'system status 1 normal, 2 closed',
`err_info` varchar(200) DEFAULT NULL COMMENT 'status description, explained here when system status is 2',
`create_at` bigint(20) DEFAULT '0' COMMENT 'creation time',
`update_at` bigint(20) DEFAULT '0' COMMENT 'update time',
PRIMARY KEY (`id`) CLUSTERED,
UNIQUE KEY `uniq_system_name_idx` (`name`),
UNIQUE KEY `uniq_system_code_idx` (`code`),
KEY `key_system_create_at_idx` (`create_at`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'system table';
- Create a database in v7.2.0
CREATE DATABASE my_text_db
- Then import my_db.sql into the newly created v7.2.0 database
- Then in v7.2.0, directly using the INSERT statement or directly inserting data in Navicat reports the following error
INSERT INTO system (`name`, `code`, `url`, `description`, `status`) VALUE ("aaa", "aaa", "aaa", "aaa", 1)
Error:
Field 'id' doesn't have a default value