【问题标题】:From the production database how to change int field to char从生产数据库如何将 int 字段更改为 char
【发布时间】:2019-10-07 11:34:10
【问题描述】:

从生产数据库中,我需要将字段从 int 更改为 char。

当我在本地尝试时,我丢失了存储在该字段中的所有数据。

解决办法是什么?

【问题讨论】:

    标签: python odoo odoo-10


    【解决方案1】:

    当您更改字段field_name的类型时,Odoo将原始field重命名为field_name_moved0并创建一个名称为field_name的新字段,如果您可以访问数据库,您可以通过以下方式轻松设置值一个简单的查询:

    -- just make sure you cast the value of field_name_moved0 to varchar
    update your_table_name set field_name = field_name_moved0::varchar where field_name_moved0 is not null;
    

    注意:如果再次更改字段类型,名称将是field_name_moved1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-10
      • 2017-02-19
      • 1970-01-01
      • 2016-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-12
      相关资源
      最近更新 更多