简体   繁体   English

Redshift 不会更改列类型

[英]Redshift won't change column type

I'm trying to change a column in Redshift from varchar to integer. I've already checked and the strings are all numbers so it should force fine.我正在尝试将 Redshift 中的一列从 varchar 更改为 integer。我已经检查过,字符串都是数字,所以它应该强制执行。

When I run:当我跑步时:

alter table schema.table_name alter column "id" type int;

I get the following error:我收到以下错误:

ERROR: target data type "int8" is not supported [SQL State=0A000]错误:不支持目标数据类型“int8”[SQL State=0A000]

I've checked the Redshift documentation and just to rule out a few potentials:我检查了Redshift 文档,只是为了排除一些可能性:

  • The field is not a primary or foreign key该字段不是主键或外键
  • There's no compression encodings on it上面没有压缩编码
  • There's no default values没有默认值
  • The code is not in a transaction block该代码不在事务块中

Any pointers would be amazing, thank you!任何指针都会很棒,谢谢!

Alter column type is for varchar types - "ALTER COLUMN column_name TYPE new_data_type -- A clause that changes the size of a column defined as a VARCHAR data type."更改列类型适用于 varchar 类型 - “ALTER COLUMN column_name TYPE new_data_type -- 更改定义为 VARCHAR 数据类型的列的大小的子句。” See: https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html请参阅: https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM