mrp*_*pyo 3 postgresql types alter-table
我需要更改列数据类型。它包含形式为的文本"part1 part2 part3"。
我希望将其内容表示为数组(["part1", "part2", "part3"])。
最简单的方法是什么?我需要编写程序还是可以仅使用SQL来完成?
我正在使用PostgreSQL。
如果只想选择它作为数组:
select string_to_array(your_column, ' ')
from your_table;
Run Code Online (Sandbox Code Playgroud)
如果您永久希望将数据类型更改为例如text[]:
alter table your_table
alter your_column type text[] using string_to_array(your_column, ' ');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2921 次 |
| 最近记录: |