加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Postgresql运算符类“varchar_pattern_ops”不接受数据类型整数

发布时间:2020-12-13 18:05:29 所属栏目:百科 来源:网络整理
导读:我正在尝试将我的数据id postgresql从字符串迁移到 django中的整数,以便在sphinx搜索中使用它们.首先,我正在进行数据迁移,将数据转换为字符串整数 db.execute('''UPDATE the_table SET foo='1' WHERE foo='bar';''') 然后我正在进行架构迁移 ALTER TABLE the
我正在尝试将我的数据id postgresql从字符串迁移到 django中的整数,以便在sphinx搜索中使用它们.首先,我正在进行数据迁移,将数据转换为字符串整数
db.execute('''UPDATE the_table SET foo='1' WHERE foo='bar';''')

然后我正在进行架构迁移

ALTER TABLE the_table ALTER COLUMN col_name TYPE integer USING (col_name::integer);

喜欢它被告知here

但是我收到了一个错误

ERROR: operator class “varchar_pattern_ops” does not accept data type integer

SQL-состояние: 42804

South和pgAdmin都会发生此错误.数据是正确的 – 字符串类型为Null或整数.我究竟做错了什么?

我只能像这样重现你的错误信息:
denis=# create index test_idx on test (val varchar_pattern_ops);
CREATE INDEX
denis=# alter table test alter val type int using (val::int);
ERROR:  operator class "varchar_pattern_ops" does not accept data type integer

如果你有一个像这样的时髦索引,请尝试删除并重新创建它:

denis=# drop index test_idx;
DROP INDEX
denis=# create index test_idx on test (val);
CREATE INDEX
denis=# alter table test alter val type int using (val::int);
ALTER TABLE

相关文档:

http://www.postgresql.org/docs/current/static/indexes-opclass.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读