在mysql中插入正确列的数据时出现错误1136

mkshixfv  于 2021-06-25  发布在  Mysql
关注(0)|答案(2)|浏览(728)

我正在为一个学校项目开发一个数据库,每次我要把数据插入到一个表中,我都会得到以下结果。
错误代码:1136。列计数与第1行的值计数不匹配
我发现这是由于值后面的行的值与表本身的值的数量不同造成的。在我的数据库中,我已经验证了行数是有效的。
为了缩短时间,我只包含了一个表的信息,但是我所有的表都是这样。

DROP schema if exists `ACRS`;
CREATE SCHEMA IF NOT EXISTS `ACRS` DEFAULT CHARACTER SET utf8;
USE `ACRS`;

DROP TABLE IF EXISTS ComputerDetails;
CREATE TABLE IF NOT EXISTS ComputerDetails (
    `ComputerNumber`    INT         NOT NULL,
    `ComputerYear`      INT         NULL,
    `ComputerModel`     VARCHAR(45) NULL,
    `CPUModel`          VARCHAR(25) NULL,
    `HasMonitor`        CHAR(1)     NULL,
    `NumOfUSB`          INT         NULL,
    `HardDriveCapGB`    INT         NULL,
    `NetworkCardType`   VARCHAR(45) NULL,
    `OperatingSystem`   VARCHAR(45) NULL,
    `HasWebcam`         CHAR(1)     NULL,
    PRIMARY KEY         (`ComputerNumber`))
ENGINE = InnoDB;

INSERT INTO ComputerDetails
(   ComputerNumber,     ComputerYear,   ComputerModel,                                  CPUModel,   HasMonitor,     NumOfUSB,   HardDriveCapGB,     NetworkCardType,    OperatingSystem,    HasWebCam)
values(
(   0101,               2008,           'Dell Optoplez 980',        'Intel',    'Y',            3,          100,                'Both',         'Windows',          'Y'),
(   0102,               1985,           'IBM PS2',                  'Intel'     'N',            0,          0,                  'Wireless',     'Unix',             'Y'),
(   0103,               2011,           'Apple MacBook Pro',        'Intel'     'Y',            2,          100,                'Both',         'Mac',              'N'),
(   0104,               2011,           'Apple MacBook Pro',        'Intel'     'N',            4,          1000,               'Wired',        'Windows',          'N'),
(   0105,               2014,           'Toshiba Satellite P50A',   'AMD'       'Y',            2,          150,                'Wireless',     'Linux',            'Y'),
(   0106,               2013,           'VersaPro type VC' 'Intel', 'Intel'     'Y',            3,          105,                'Both',         'Unix',             'N'),
(   0107,               1999,           'Power Mac G3',             'Power PC'  'N',            3,          5,                  'Both',         'Mac',              'Y'),
(   0108,               2007,           'Mac Pro',                  'Intel'     'Y',            4,          200,                'Wireless',     'Mac',              'N'),
(   0109,               2000,           'Power Mac x86',            'Intel'     'Y',            4,          600,                'Wired',        'Windows',          'Y'),
(   0110,               2018,           'Apple iMac 4K',            'Intel'     'Y',            3,          50000,              'Both',         'Mac/Windows',      'Y'),
(   0111,               2013,           'VersaPro type VC',         'AMD'       'Y',            3,          640,                'Both',         'Unix',             'Y'),
(   0112,               2016,           'iMac',                     'Intel'     'Y',            4,          630,                'Wireless',     'Unix',             'Y'),
(   0113,               2013,           'VersaPro type VC',         'Intel'     'Y',            3,          250,                'Wired',        'Windows',          'N'),
(   0114,               2015,           'Sony VAIO Z',              'Intel'     'Y',            17,         2,                  'Both',         'Mac',              'N'),
(   0115,               1999,           'Power Mac G3',             'Power PC'  'N',            2,          30,                 'Wired',        'Mac',              'N'),
(   0116,               2013,           'VersaPro type VC',         'Intel'     'Y',            4,          350,                'Both',         'Windows',          'Y'),
(   0117,               2008,           'Dell Optoplez 980',        'Intel'     'Y',            3,          150,                'Both',         'Linux',            'Y'),
(   0118,               2008,           'Dell Optoplez 980',        'Intel'     'Y',            1,          200,                'Wireless',     'Linux',            'Y'),
(   0119,               2010,           'Toshiba Satellite 750',    'Intel'     'Y',            2,          140,                'Both',         'Unix',             'Y'),
(   0120,               2018,           'HP Z2 Mini G3',            'AMD'       'Y',            3,          500,                'Wired',        'Unix',             'N')
);
wsewodh2

wsewodh21#

这个问题最后缺少逗号。我的错。

rvpgvaaj

rvpgvaaj2#

尝试通过删除值中额外的左括号和右括号来执行以下查询,首先在phpmyadmin上运行它…希望这有帮助

INSERT INTO ComputerDetails
(   ComputerNumber,     ComputerYear,   ComputerModel,                                  CPUModel,   HasMonitor,     NumOfUSB,   HardDriveCapGB,     NetworkCardType,    OperatingSystem,    HasWebCam)
values
(   0101,               2008,           'Dell Optoplez 980',        'Intel',    'Y',            3,          100,                'Both',         'Windows',          'Y'),
(   0102,               1985,           'IBM PS2',                  'Intel'     'N',            0,          0,                  'Wireless',     'Unix',             'Y'),
(   0103,               2011,           'Apple MacBook Pro',        'Intel'     'Y',            2,          100,                'Both',         'Mac',              'N'),
(   0104,               2011,           'Apple MacBook Pro',        'Intel'     'N',            4,          1000,               'Wired',        'Windows',          'N'),
(   0105,               2014,           'Toshiba Satellite P50A',   'AMD'       'Y',            2,          150,                'Wireless',     'Linux',            'Y'),
(   0106,               2013,           'VersaPro type VC' 'Intel', 'Intel'     'Y',            3,          105,                'Both',         'Unix',             'N'),
(   0107,               1999,           'Power Mac G3',             'Power PC'  'N',            3,          5,                  'Both',         'Mac',              'Y'),
(   0108,               2007,           'Mac Pro',                  'Intel'     'Y',            4,          200,                'Wireless',     'Mac',              'N'),
(   0109,               2000,           'Power Mac x86',            'Intel'     'Y',            4,          600,                'Wired',        'Windows',          'Y'),
(   0110,               2018,           'Apple iMac 4K',            'Intel'     'Y',            3,          50000,              'Both',         'Mac/Windows',      'Y'),
(   0111,               2013,           'VersaPro type VC',         'AMD'       'Y',            3,          640,                'Both',         'Unix',             'Y'),
(   0112,               2016,           'iMac',                     'Intel'     'Y',            4,          630,                'Wireless',     'Unix',             'Y'),
(   0113,               2013,           'VersaPro type VC',         'Intel'     'Y',            3,          250,                'Wired',        'Windows',          'N'),
(   0114,               2015,           'Sony VAIO Z',              'Intel'     'Y',            17,         2,                  'Both',         'Mac',              'N'),
(   0115,               1999,           'Power Mac G3',             'Power PC'  'N',            2,          30,                 'Wired',        'Mac',              'N'),
(   0116,               2013,           'VersaPro type VC',         'Intel'     'Y',            4,          350,                'Both',         'Windows',          'Y'),
(   0117,               2008,           'Dell Optoplez 980',        'Intel'     'Y',            3,          150,                'Both',         'Linux',            'Y'),
(   0118,               2008,           'Dell Optoplez 980',        'Intel'     'Y',            1,          200,                'Wireless',     'Linux',            'Y'),
(   0119,               2010,           'Toshiba Satellite 750',    'Intel'     'Y',            2,          140,                'Both',         'Unix',             'Y'),
(   0120,               2018,           'HP Z2 Mini G3',            'AMD'       'Y',            3,          500,                'Wired',        'Unix',             'N');

相关问题