简体   繁体   English

我尝试添加的新列数据的 PSQL/Spring Boot 类型语法错误

[英]PSQL/Spring Boot type syntax error for new column data that I am trying to add

Using Postgres and Spring Boot.使用 Postgres 和 Spring Boot。 Running into the following error when I try to add the following column and data to my table.当我尝试将以下列和数据添加到表中时遇到以下错误。

psql:resorts.sql:51: ERROR:  invalid input syntax for type smallint: "https://someurl.com/that-im/trying-to-add/"
LINE 24:     'https://someurl.com/that-im/trying-to-add/'

Where I add in the column in my Spring Boot Model the column above is a short but I clearly define this column as a String as seen here:我在 Spring Boot Model 的列中添加了上面的列,但我清楚short将此列定义为String ,如下所示:

  @Column(name = "things")
  private short things;

  @Column(name = "item_url")
  private String itemUrl;

My sql file where I insert the data into the database looks like this:我将数据插入数据库的 sql 文件如下所示:

INSERT INTO table (
    ...,
    things,
    item_url
) VALUES (
    ...,
    5,
    'https://someurl.com/that-im/trying-to-add/'
),(

When I remove the column for item_url and remove it and the url from the SQL file everything works, but as soon as I put them back in I get the error above.当我删除item_url的列并从 SQL 文件中删除它和 url 时,一切正常,但是一旦我把它们放回去,我就会得到上面的错误。 Any help would be appreciated.任何帮助,将不胜感激。

What ended up being the case was that when the table in my database was initially created I had accidentally labeled the type for the item_url as a short.最终的情况是,当我最初创建数据库中的表时,我不小心将item_url的类型标记为短。 Despite changing it in the SB model file to a String it still wouldn't take on the table.尽管在 SB 模型文件中将其更改为字符串,但它仍然不会出现在桌面上。

From there I attempted to DROP TABLE IF EXISTS which deleted my table but for some reason would not allow to re-create a table with the old name.从那里我尝试DROP TABLE IF EXISTS删除了我的表,但由于某种原因不允许使用旧名称重新创建表。 So I went into the SB model file and SQL seeder file and changed the name of the table to something else.所以我进入了 SB 模型文件和 SQL 种子文件并将表的名称更改为其他名称。 From there it was able to create aa new table with all of the correct data and types with no errors.从那里它能够创建一个包含所有正确数据和类型且没有错误的新表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我在 PostgreSQL 中遇到语法错误问题。 我正在尝试添加一个查询,但它给了我一个错误 - I am having issues with a syntax error in PostgreSQL. I am trying to add a query and it is giving me an error 下面是我遇到语法错误的 psql 代码。 我正在尝试在我的 test_route 数据库上创建触发器 function - Below is the psql code in which I am having syntax error. I am trying to create a trigger function on my test_route database PSQL-修改列的数据类型 - PSQL - Modify data type of column 为什么在 PSQL 中尝试将行插入表时会收到语法错误? - Why am I receiving syntax errors when trying to insert line into table in PSQL? 如何使用“psql”解决“错误:列缺少数据”? - How do I solve "ERROR: missing data for column" with "psql"? 当我想添加具有条件值的新列时,我在 Liquibase 中收到 Sql 语法错误 - I get an Sql syntax error with Liquibase when I want to add a new column with conditional value 尝试使用if / else子句创建新列时出现SQL语法错误 - SQL syntax error while trying to create a new column with an if/else clause “ +”或附近的psql语法错误 - psql syntax error at or near “+” 在命令行中输入psql时,我应该登录什么? - What am I logging in as when I type psql in the command line? 为什么我无法获取 psql 中的特定列 - Why I am not able to get the specific column in psql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM