Increasing the size of character varying type in postgres without data loss

后端 未结 6 2111
春和景丽
春和景丽 2021-02-06 20:54

I need to increase the size of a character varying(60) field in a postgres database table without data loss.

I have this command

alter table client_deta         


        
6条回答
  •  旧时难觅i
    2021-02-06 21:33

    Referring to this documentation, there would be no data loss, alter column only casts old data to new data so a cast between character data should be fine. But I don't think your syntax is correct, see the documentation I mentioned earlier. I think you should be using this syntax :

    ALTER [ COLUMN ] column TYPE type [ USING expression ]

    And as a note, wouldn't it be easier to just create a table, populate it and test :)

提交回复
热议问题