<bdo id="vljxk"><rt id="vljxk"><noframes id="vljxk"><noframes id="vljxk"><noframes id="vljxk"><rt id="vljxk"></rt><rt id="vljxk"></rt><noframes id="vljxk"><rt id="vljxk"><delect id="vljxk"></delect></rt><noframes id="vljxk"><rt id="vljxk"></rt><noframes id="vljxk"><noframes id="vljxk"><rt id="vljxk"></rt>

當前位置:首頁 >  站長 >  數據庫 >  正文

postgresql數據添加兩個字段聯合唯一的操作

 2021-04-26 16:54  來源: 腳本之家   我來投稿 撤稿糾錯

  阿里云優惠券 先領券再下單

這篇文章主要介紹了postgresql數據添加兩個字段聯合唯一的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧。

我就廢話不多說了,大家還是直接看代碼吧~

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

補充:一行數據中的 多字段值根據連接符拼接

1concat_ws(':',a,b)

幾行數據中的 同一 單字段值根據連接符拼接

1string_agg(c,' \r\n ')

如果要將多個字段的值拼接成一個:

1string_agg(concat_ws(':',a,b),' \r\n ' order by a asc) as xxx

結果:

還可以對進行排序

例子:

1string_agg(concat_ws('|',login_name,user_name),',') as jcry,

返回結果:

以上為個人經驗,希望能給大家一個參考。

文章來源:腳本之家

來源地址:https://www.jb51.net/article/205368.htm

申請創業報道,分享創業好點子。點擊此處,共同探討創業新機遇!

相關文章

熱門排行

信息推薦