pgsql拆解字符串
时间: 2024-01-20 20:16:09 浏览: 85
Sql拆分字符串
以下是pgsql拆解字符串的示例:
```sql
-- 引用[1]
-- 使用split_part函数拆解字符串
SELECT split_part('apple,banana,orange', ',', 1) AS part1,
split_part('apple,banana,orange', ',', 2) AS part2,
split_part('apple,banana,orange', ',', 3) AS part3;
```
输出结果:
```
part1 | part2 | part3
--+--+---------
apple | banana | orange
```
```sql
-- 引用[2]
-- 使用string_to_array函数拆解字符串
SELECT unnest(string_to_array('apple,banana,orange', ',')) AS part;
```
输出结果:
```
part
-------
apple
banana
orange
```
阅读全文