Postgresql 将列拆分为行

use*_*817 4 postgresql

我有 2 列,其中包含城镇列表,我想将城镇分成几行

user 1 | [town1,town2,town3]
Run Code Online (Sandbox Code Playgroud)

我想将其分成几行:

user 1 | town 1
user 1 | town 2
user 1 | town 3
Run Code Online (Sandbox Code Playgroud)

Rah*_*thi 5

尝试这个:

SELECT 
    username, 
    regexp_split_to_table(towns, E',') 
FROM yourTable
Run Code Online (Sandbox Code Playgroud)

SQLFIDDLE演示