使用 PostgreSQL 9.3。 有一列包含这样的文件名值:
qwerty.swf
some.image.jpg
some.other.image.jpg
此列也允许空值。
如何在sql查询中从该列获取文件扩展名?
最佳答案
尝试:
with mytable as (
select unnest(string_to_array($$qwerty.swf
some.image.jpg
some.other.image.jpg
test
$$,E'\n')) filename)
select filename,substring(filename from '\.([^\.]*)$')
from mytable
关于sql - 如何从 PostgreSQL 中的文件名获取文件扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38102854/