如何在postgresql中为数据添加两个字段

介绍

这期内容当中小编将会给大家带来有关如何在postgresql中为数据添加两个字段,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

alter  table  tb_safety_commitment  add  constraint  uk_mac_vendor  unique  (company_code promise_date);

<强>补充:一行数据中的多字段值根据连接符拼接

concat_ws (& # 39;: & # 39; a, b)

几行数据中的同一单字段值根据连接符拼接

string_agg (c & # 39;, \ r \ n  & # 39;)

如果要将多个字段的值拼接成一个:

string_agg (concat_ws (& # 39;: & # 39; a, b), & # 39;, \ r \ n  & # 39;, order  by  a  asc), as  xxx

结果:

如何在postgresql中为数据添加两个字段

还可以对进行排序

例子:

string_agg (concat_ws (& # 39; | & # 39;, login_name, user_name), & # 39;, & # 39;), as  jcry,

返回结果:

如何在postgresql中为数据添加两个字段

上述就是小编为大家分享的如何在postgresql中为数据添加两个字段了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。

如何在postgresql中为数据添加两个字段