首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SQLite:一般错误:1所有值必须有相同数目的术语

SQLite:一般错误:1所有值必须有相同数目的术语
EN

Stack Overflow用户
提问于 2022-04-27 19:23:08
回答 1查看 470关注 0票数 0

此表引发“所有值必须具有相同数目的术语”错误。我最初确实分配了列而没有插入任何内容,但是即使在更改了明显的错误示例之后,错误代码仍然存在。

代码语言:javascript
复制
CREATE TABLE plants (
      auto_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
      plant_id TEXT NOT NULL UNIQUE,
      plant_name TEXT NOT NULL,
      genus TEXT NOT NULL,
      description TEXT NOT NULL,
      plant_type TEXT NOT NULL,
      file_name TEXT NOT NULL,
      file_ext TEXT NOT NULL
    );
    
    
    INSERT INTO
      plants (auto_id, plant_id, plant_name, genus, description, plant_type, file_name,  file_ext)
    VALUES
      (1,'GA_13', 'Pink Muhly Grass', 'Muhlenbergia capillaris', "Muhly Grass is a perennial that takes full sun", "grass",'plant1.jpg', 'jpg'),
      (2, 'GA_01','Feather reed grass', 'Calamagrostis x acutiflora', "Feather reed grass is a perennial that takes full sun", 'grass','plant2.jpg', 'jpg'),
      (3, 'SH_32','Smooth Shadbush', 'Amelanchier laevis', "The shadbush is a perennial that can take full sun or partial shade", 'shrub','plant3.jpg', 'jpg'),
      (4, 'TR_29','Chestnut Oak', 'Quercus montana', "The chestnut oak is a perennial that takes full sun", 'tree','plant4.jpg', 'jpg'),
      (5, 'GA_20','Sideoats Grama', 'Bouteloua curtipendula is a perennial that takes full sun', 'grass','plant5.jpg', 'jpg'),
      (6, 'GR_14','Feverfew', 'Tanasetum parthenium', "Tanacetum partheniumis a perennial that takes full sun", 'groundcover','plant6.jpg', 'jpg'),
      (7, 'GA_02','Prairie Cord Grass', 'Spartina pectinata', "Spartina pectinata is not a perennial but takes partial shade or full sun",'grass', 'plant7.jpg', 'jpg'),
      (8, 'FE_01','Christmas Fern', 'Polystichum acrostichoides', "Polystichum acrostichoides is a perennial that prefers full or partial shade", 'fern','plant8.jpg', 'jpg'),
      (9, 'VI_15','Climbing Hydrangea', 'Hydrangea anomala', "Hydrangea petiolaris is a perennial that prefers full or partial shade", 'vine','plant9.jpg', 'jpg'),
      (10,'FL_03', 'New England Aster', 'Aster novae angliae', "Symphyotrichum novae-angliae is a perennial that prefers either full sun or partial shade", 'flower','plant10.jpg', 'jpg'),
      (11,'SH_34', 'Nannyberry', 'Viburnum lentago', "Viburnum lentago, the nannyberry, is a perennial that prefers either full sun or partial shade", 'shrub','plant11.jpg', 'jpg'),
      (12,'FL_30', 'Hyssop', 'Hyssopus officinalis', "Hyssopus officinalis or hyssop is a perennial shrub that prefers either full sun or partial shade", 'flower','plant12.jpg', 'jpg');

此表抛出“近"(":语法错误”)。我以前收到过这个错误,但是使用不同的代码,很难重新编程。

代码语言:javascript
复制
CREATE TABLE play_types (

  topo_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
  topo TEXT NOT NULL,
  plant_id INTEGER NOT NULL,
    FOREIGN KEY(plant_id) REFERENCES plants(auto_id)

);

INSERT INTO play_types (topo_id,plant_id, topo)
VALUES
(1, 1,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(2, 2,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(3, 3,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(4, 4,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(5, 5,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(6, 6,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(7, 7,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(8, 8,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(9, 9,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(10, 10,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(11, 11,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
(12, 12,"edible scent sound tactile viual exploratory sensory constructive physical imaginative restorative rules bio");
EN

回答 1

Stack Overflow用户

发布于 2022-04-27 19:46:10

在第一种情况下,所有插入必须具有字段列表中指示的相同数量的数据元素;一次检查显示id 5的行小于8。

在第二种情况下,根据SQLite CREATE TABLE 语法,列定义必须用逗号分隔,因此子句约束FOREIGN KEY被解释为格式错误的列定义,因为前面的分隔逗号。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72034256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档