当前位置:网站首页>【170】PostgreSQL 10字段类型从字符串修改成整型,报错column cannot be cast automatically to type integer
【170】PostgreSQL 10字段类型从字符串修改成整型,报错column cannot be cast automatically to type integer
2022-06-27 15:23:00 【zhangchao19890805】
错误重现
原来的字段类型是 character varying 改成 integer
ALTER TABLE table_name ALTER COLUMN column_name TYPE integer
PostgreSQL 10 报错:
ERROR: column "column_name" cannot be cast automatically to type integer
HINT: You might need to specify "USING column_name::integer".
SQL state: 42804
解决方法
确保要修改的字段中没有字符串数据,如果有的话需要设为NULL。
把修改字段的语句改成下面:
ALTER TABLE table_name ALTER COLUMN column_name TYPE integer using column_name::integer;
注意这里必须要有 using column_name::integer 否则会报错。
边栏推荐
- QT 如何在背景图中将部分区域设置为透明
- Je veux acheter des produits à revenu fixe + mais je ne sais pas quels sont ses principaux investissements.
- ERROR L104: MULTIPLE PUBLIC DEFINITIONS
- 巧用redis实现点赞功能,它不比mysql香吗?
- Multithreading Basics (III)
- CAS comparison and exchange
- 关于 Spartacus 的 sitemap.xml 问题
- SQL parsing practice of Pisa proxy
- Privacy computing fat offline prediction
- Redis master-slave replication, sentinel mode, cluster cluster
猜你喜欢
随机推荐
Introduction to TTCAN brick moving
Multithreading Basics (III)
Use of abortcontroller
Je veux acheter des produits à revenu fixe + mais je ne sais pas quels sont ses principaux investissements.
Abnormal analysis of pcf8591 voltage measurement data
Notes learning summary
Practice of constructing ten billion relationship knowledge map based on Nebula graph
专家:让你低分上好校的都是诈骗
Pri3d: a representation learning method for 3D scene perception using inherent attributes of rgb-d data
volatile与JMM
Sword finger offer II 039 Histogram maximum rectangular area monotonic stack
隱私計算FATE-離線預測
All you want to know about large screen visualization is here
Strong, weak, soft and virtual references of ThreadLocal
AbortController的使用
Let's talk about the process of ES Indexing Documents
優雅的自定義 ThreadPoolExecutor 線程池
522. longest special sequence II / Sword finger offer II 101 Split equal sum subset
Computer screen splitting method
Google tool splits by specified length









