Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I am getting the following error when i give the SQL Query INSERT INTO items VALUES (10001,0,'','',10001,'Free memory','memory[free]',30,30,0,0,NULL,NULL,NULL,0,0,''); The Error Message is ERROR 1136: Column count doesn't match ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2003
    Location
    India
    Posts
    10

    MySQL Error


    Hi all,

    I am getting the following error when i give the SQL Query
    INSERT INTO items VALUES (10001,0,'','',10001,'Free memory','memory[free]',30,30,0,0,NULL,NULL,NULL,0,0,'');
    The Error Message is
    ERROR 1136: Column count doesn't match value count at row 1

    while designing the schema i have given the following parameters in the Table items

    CREATE TABLE items (
    itemid int(4) NOT NULL auto_increment,
    type int(4) DEFAULT '0' NOT NULL,
    snmp_community varchar(64) DEFAULT '' NOT NULL,
    snmp_oid varchar(255) DEFAULT '' NOT NULL,
    snmp_port int(4) DEFAULT '161' NOT NULL,
    hostid int( NOT NULL,
    description varchar(255) DEFAULT '' NOT NULL,
    key_ varchar(64) DEFAULT '' NOT NULL,
    delay int(4) DEFAULT '0' NOT NULL,
    history int(4) DEFAULT '0' NOT NULL,
    lastdelete int(4) DEFAULT '0' NOT NULL,
    nextcheck int(4) DEFAULT '0' NOT NULL,
    lastvalue varchar(255) DEFAULT NULL,
    lastclock int(4) DEFAULT NULL,
    prevvalue varchar(255) DEFAULT NULL,
    status int(4) DEFAULT '0' NOT NULL,
    value_type int(32) DEFAULT '0' NOT NULL,
    trapper_hosts varchar(255) DEFAULT '' NOT NULL,
    PRIMARY KEY (itemid),
    UNIQUE shortname (hostid,key_),
    KEY (hostid),
    KEY (nextcheck),
    KEY (status)
    ) type=InnoDB;

    Can anyone suggest me where the problem is?

    Thanks
    Balaji R

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Where there should be snmp_port and hostid, I can only see that you're inserting one numeric value.

  3. #3
    Just Joined!
    Join Date
    Nov 2002
    Location
    USA
    Posts
    99
    You are trying to insert 17 values into a table that is defined to have 18 fields. Unless you specify a column list, you must pass in the exact count of values for the count of fields regardless of the default values. The default values only work when supplying a column list. I suggest reading the MySQL documentation for a more complete explanation of the syntax for SQL statements in MySQL. See: http://www.mysql.com/documentation/index.html

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •