What delimiter should be used for string_to_array command at PostgreSQL for a tab separated text?

一世执手 提交于 2019-12-11 04:43:55

问题


I'm querying a one-column table, the output of the query is of type text. I want to check the cardinality of the results. I'm using the string_to_array command, but I don't know what I should put for the delimiter. The following two commands don't work:

select rec from papers_stg where cardinality(string_to_array(rec,'    ')) <> 11
select rec from papers_stg where cardinality(string_to_array(rec,'\t')) <> 11

Here are the first two rows of table papers_stg:

7B5EDC52        Antibacterial Activity and Post-Antibiotic Effect of Flurithromycin Compared with Other Macrolides and Penicillins Against Periodontal Pathogens        antibacterial activity and post antibiotic effect of flurithromycin compared with other macrolides and penicillins against periodontal pathogens        2013    2013/07/18      10.1179/joc.2001.13.3.255       Journal of Chemotherapy journal of chemotherapy 0794F580                19555
7932AE5F        In Vitro Activity of Cefdinir against Respiratory Pathogens Isolated in Sicily with Reference to Beta-Lactamase Production      in vitro activity of cefdinir against respiratory pathogens isolated in sicily with reference to beta lactamase production      2013    2013/07/18              Journal of Chemotherapy journal of chemotherapy 0794F580                19555

And here is the table description:

 Table "public.papers_stg"
 Column | Type | Modifiers 
--------+------+-----------
 rec    | text | 

回答1:


String Constants with C-style Escapes

string_to_array(rec, E'\t')


来源:https://stackoverflow.com/questions/41394050/what-delimiter-should-be-used-for-string-to-array-command-at-postgresql-for-a-ta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!