插入行时出现此错误。我重置了自动增量,验证成功。它显示最大值:18446744073709551615,我将其改回16,然后当我们插入行时,它再次出现问题。到目前为止,我们唯一注意到的是它被设置为BIGINT 19,而其他表为BIGINT 20。还有其他想法吗?
错误:
SQL错误(1467):无法从存储引擎读取自动增量值
我使用的是版本10.2.12-MariaDB。大小:63.2 MiB项目:63.2 MiB表:浏览次数:42功能:2程序:2
插入:
Insert into products
(ProductID,`Name`,Type,Price,MSRP,ReorderAt,DepartmentID,DateAdded,Status,QtyOnHand, DefaultTaxAccount,qtyonOrder,AverageCost,CogsAccount,IncomeAccount,AssetType,DiscountRate,Track,DefaultCost)
values
(3901, 'Test', 1, 3.00, 3.00, 0, 5, '1900-01-01', 1, 0, 320, 0, 0, 29, 7, 11, 0, '0', 0)
下表为:
CREATE TABLE `products` (
`ProductIndex` bigint(19) NOT NULL AUTO_INCREMENT,
`ProductID` bigint(19) DEFAULT 0,
`Name` longtext DEFAULT NULL,
`Type` int(11) DEFAULT 1,
`Description` longtext DEFAULT NULL,
`PartNumber` varchar(50) DEFAULT NULL,
`UPC` varchar(50) DEFAULT NULL,
`Price` decimal(19,4) DEFAULT 0.0000,
`MSRP` decimal(19,4) DEFAULT 0.0000,
`ReorderAt` decimal(30,4) DEFAULT 0.0000,
`DepartmentID` bigint(19) DEFAULT -1,
`DateAdded` date DEFAULT NULL,
`Status` int(11) DEFAULT 1,
`Version` bigint(20) DEFAULT 0,
`QtyOnHand` decimal(30,4) DEFAULT 0.0000,
`Track` tinyint(1) DEFAULT 0,
`DefaultTaxAccount` int(11) DEFAULT 57,
`OLDid` longtext DEFAULT NULL,
`qtyonOrder` decimal(30,4) DEFAULT 0.0000,
`LastRecieved` datetime DEFAULT NULL,
`margin` decimal(19,4) DEFAULT NULL,
`CogsAccount` bigint(20) DEFAULT 2,
`IncomeAccount` bigint(20) DEFAULT 1,
`AssetType` bigint(20) DEFAULT 91,
`AverageCost` decimal(19,4) DEFAULT 0.0000,
`DiscountRate` decimal(19,4) DEFAULT 0.0000,
`QtyOnHold` decimal(30,4) DEFAULT 0.0000,
`Points` bigint(20) DEFAULT 0,
`Amount` decimal(19,4) DEFAULT 0.0000,
`ImageID` bigint(20) DEFAULT 0,
`ImageDate` timestamp NULL DEFAULT current_timestamp(),
`GuidID` varchar(100) DEFAULT NULL,
`Frequency` int(11) DEFAULT 3,
`NumRecurrence` int(11) DEFAULT 0,
`NoEnd` tinyint(1) DEFAULT 0,
`DefaultCost` decimal(19,4) DEFAULT 0.0000,
`SkipPrompt` tinyint(1) DEFAULT 0,
`UseScaleWeight` tinyint(1) DEFAULT 0,
`SaleOnline` tinyint(1) DEFAULT 0,
`PackageWeight` decimal(19,4) DEFAULT 0.0000,
PRIMARY KEY (`ProductIndex`),
KEY `prdID` (`ProductID`,`Version`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8
下面是INI文件(my.ini位于mysql文件夹中):
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name dbserver generated for @plazsoft.com at 2017-01-14 18:20:14
[mysql]
# CLIENT #
port = 3306
socket = /tmp/mysql.sock
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /tmp/mysql.sock
pid-file = C:/Program Files/MariaDB 10.1/data/mysql.pid
# MyISAM #
key-buffer-size = 32M
myisam-recover = FORCE,BACKUP
# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 1000000
skip-name-resolve
sql-mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate-is-now = 1
innodb = FORCE
# DATA STORAGE #
datadir = C:/Program Files/MariaDB 10.1/data
# BINARY LOGGING #
log-bin = mysql-bin
expire-logs-days = 14
sync-binlog = 1
# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 2
query-cache-size = 128M
max-connections = 500
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 1024
table-open-cache = 256
# INNODB #
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 2G
# LOGGING #
log-error = C:/Program Files/MariaDB 10.1/data/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = C:/Program Files/MariaDB 10.1/data/mysql-slow.log
1条答案
按热度按时间4xy9mtcn1#
我发现这个问题可能是由于我们在一些自动递增的ID中添加了负值。
每个表只能有一个AUTO_INCREMENT列,它必须被索引,并且它不能具有DEFAULT值。AUTO_INCREMENT列仅在只包含正值时才能正常工作。插入负数被视为插入了非常大的正数。这样做是为了避免数字从正数换到负数时出现精度问题,同时也是为了确保不会意外地得到AUTO_INCREMENT列包含0的INCREMENT列。
https://mariadb.com/kb/en/auto_increment-faq/