列数不匹配

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了列数不匹配相关的知识,希望对你有一定的参考价值。

[尝试向表中插入一些信息,我收到以下错误“列数在row1上不值”。此错误看似很清楚,但据我所知,已正确输入了信息。

任何帮助将不胜感激,

提前感谢!!!

create table patient(
  patientno Int(6) unsigned zerofill auto_increment, -- see Numbers.sql next week
  title ENUM ('Mr.', 'Mrs.', 'Miss.', 'Ms.','Dr.','Fr.','Rev.'), --  constraint on values entered into the column, default value is first element in list, if wrong data entered mysql truncates the illegal value to  ' ' (an empty string).
  pname varchar(45) not null default 'Smith',
  degree SET ('B Sc','B Eng','B Comm','M Sc','Phd') not null ,
  job ENUM ('CLERK','SALESMAN','MANAGER','ANALYST','PRESIDENT'),
  assignedentist smallint unsigned,
  currency_symbol varchar(10),
  salary DECIMAL(6,2) unsigned,# 6 is the total number of digits and 2 is the number of digits after the decimal point, values that can be stored in the salary column range from -9999.99 to 9999.99
  comm DECIMAL(6,2) unsigned, # values that can be stored in the comm column range from -9999.99 to 9999.99
  appno TINYINT unsigned not null default 20,
  last_update  TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  picture LONGBLOB DEFAULT NULL,           # Picture in DATABASE as BLOB (up to 4.2GB)
  picture_path varchar(20) DEFAULT NULL,   # Path to where picture is stored in file system,
  primary key (patientno)
)  Engine=InnoDB;



INSERT INTO patient (patientno, title, pname, degree, job, assignedentist, currency_symbol, salary, comm, appno,picture,picture_path) VALUES
(7369, 'Miss.','SMITH', ('B Sc,M Sc,Phd'),'Developer', 7566, '2010-12-17', 0xE282AC,800.23, NULL, 20,load_file('c:/teeth/teeth1.jpg'),'/teeth1.jpg'),
(7499, 'Mr.','ALLEN', ('B Eng,Phd'),'SALESMAN', 7698, '2011-02-20',0xE282AC, 1600.56, 300.23, 30, load_file('c:/teeth/teeth2.jpg'),'/teeth2.jpg'),
(7521, 'Mr.','WARD', ('B Eng,B Comm'),'Self Employed', 7566, '2011-02-22',0xE282AC, 1250, 500, 30,load_file('c:/teeth/teeth3.png'),'/teeth3.png'),
(7566, 'Rev.','JONES', ('B Sc,M Sc,Phd'),'Lecturer', 7839, '2011-04-02',0xE282AC, 2976, NULL, 20, load_file('c:/teeth/teeth4.jpg'),'/teeth4.jpg'),
(7654, 'Fr.','MARTIN', ('B Comm,Phd'),'SALESMAN', 7698, '2011-09-28',0xE282AC, 1250, 1400, 30,load_file('c:/teeth/teeth5.jpg'),'/teeth5.jpg'),
(7698, 'Mr.','BLAKE', ('B Sc,B Eng,B Comm,M Sc,Phd'),'MANAGER', 7839, '2011-01-05', 0xE282AC,2850, NULL, 30, load_file('c:/teeth/teeth6.png'),'/teeth6.png'),
(7782, 'Mr.','CLARK', ('B Comm,Phd'),'MANAGER', 7839, '2011-09-06',0xE282AC, 2450, NULL, 10, load_file('c:/teeth/teeth7.jpg'),'/teeth7.jpg'),
(7788, 'Mr.','SCOTT', ('B Comm,Phd'),'Army', 7788, '2012-12-09',0xE282AC, 3000, NULL, 20, load_file('c:/teeth/teeth8.jpg'),'/teeth8.jpg'),
(7839, 'Miss.','KING',('B Comm'), 'PRESIDENT', NULL, '2011-11-17',0xE282AC, NULL, NULL, 10, load_file('c:/teeth/teeth9.jpg'),'/teeth9.jpg'),
(7844, 'Mr.','TURNER', ('B Comm,Phd'),'UX', 7698, '2011-09-08', 0xE282AC,1500, 0, 30, load_file('c:/teeth/teeth10.jpg'),'/teeth10.jpg'),
(7876, 'Mrs.','ADAMS',('B SC,M Sc') ,'Database Desinger', 7788, '2013-12-01',0xE282AC, 1100, NULL, 20, load_file('c:/teeth/teeth1.jpg'),'/teeth1.jpg'),
(7900, 'Mr.','JAMES', ('B Comm,Phd'),'CLERK', 7698, '2011-12-03', 0xE282AC,950, NULL, 30, load_file('c:/teeth/teeth2.jpg'),'/teeth2.jpg'),
(7902, 'Mrs.','FORD', ('B Comm,M Sc,Phd'),'Data ANALYST', 7902, '2011-12-01', 0xE282AC,3000, NULL, 20,load_file('c:/teeth/teeth4.jpg'),'/teeth4.jpg'),
(7934, 'Mr.','MILLER',('B SC,M Sc') ,'CLERK', 7782, '2012-06-23',0xE282AC, 1300, NULL, 10, load_file('c:/teeth/teeth8.jpg'),'/teeth8.jpg');

答案
日期仍然存在,例如:'2010-12-17'
另一答案
您的INSERT语句命名为12列,但是在VALUES中,您有13个值。

您必须具有与列数相同的值数。

此外,我也不确定'2010-12-17'的值是否适合currency_symbol

我认为您只需要仔细检查每一列即可对INSERT语句中的值进行配对。看起来很腥。

以上是关于列数不匹配的主要内容,如果未能解决你的问题,请参考以下文章

列数不匹配

例外:尽管范围是从数据创建的,但数据中的列数与范围中的列数不匹配

异常:数据中的列数与范围内的列数不匹配

RedShift Copy - 列数不匹配 - 可以在卸载中指定吗?

PHP ~ 列数与第 1 行的值数不匹配

DB::Exception: 从 localhost:8000 接收。 DB::Exception:列数不匹配