H2数据库无法找到现有列

问题描述 投票:0回答:1

我的配置文件:

# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2

# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

我的data.sql脚本是这样的:

CREATE TABLE IF NOT EXISTS people (
   ID INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
   vname varchar(255) not null
);

INSERT INTO people(vname) VALUES ('Chuck Norris');

执行此操作时,INSERT失败并显示错误:找不到“VNAME”列。

  1. 为什么列名自动全部被限制?这会影响我的INSERT命令吗?
  2. 我刚刚创建了表,为什么不能INSERT找到v name列?
sql h2
1个回答
2
投票

您是否已经创建了没有VNAME列的表PEOPLE?如果表已存在,则SQL不会触及它。删除数据库文件,然后重试......

© www.soinside.com 2019 - 2024. All rights reserved.