我有一个电影桌,看起来像:
1::Toy Story (1995)::Animation|Children's|Comedy
2::Jumanji (1995)::Adventure|Children's|Fantasy
3::Grumpier Old Men (1995)::Comedy|Romance
使用SQLite Studio,如何将“类别”列拆分为多行,如下所示:
1::Animation
1::Children's
1::Comedy
2::Adventure
2::Children's
2::Fantasy
3::Comedy
3::Romance
以前,我能够使用以下命令在oracle中实现此目标:
INSERT INTO TMovie(MovieID,categories,category_name)
select DISTINCT MD.MovieID, MD.movie_categories,
trim(regexp_substr(MD.movie_categories, '[^|]+', 1, levels.column_value))
from
MD,
table(cast(multiset(select level from dual connect by level <= length (regexp_replace(MD.movie_categories, '[^|]+')) + 1) as sys.OdciNumberList)) levels