我正在尝试将我的数据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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。