【问题标题】:Error in SQL : invalid input syntax for type integer:SQL 中的错误:整数类型的输入语法无效:
【发布时间】:2023-01-26 23:41:52
【问题描述】:

我正在尝试对 customer_idvarchar constraint 中给出的查询使用强制转换函数。 我正在尝试使用 cast 将其修改为 int,以便我可以在我的查询中使用它,但它不起作用,我不明白为什么。

我期待着

select cast (customer_id as integer) as cust_id from customer

最终会以整数形式返回客户 ID,以便我可以在查询中运行它,但它只是给出了我的错误消息。

【问题讨论】:

标签: sql postgresql


【解决方案1】:

你试过用int替换integer

select cast (customer_id as int) as cust_id from customer

bigint

select cast (customer_id as bigint) as cust_id from customer

另请注意,SQL documentationintbigintinteger并未正式支持CAST()

【讨论】:

  • 不幸的是,我尝试执行上面的两个查询,但仍然收到相同的错误消息。
猜你喜欢
  • 1970-01-01
  • 2014-07-17
  • 1970-01-01
  • 1970-01-01
  • 2012-12-21
  • 2020-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多