簡體   English   中英

在 postgresql 中的 jsonb[] 類型列中插入數據的正確語法是什么

[英]What is the correct syntax of inserting the data inside the jsonb[] type column inside postgresql

由於我們只能在 jsonb 列中存儲 json 對象數組,那么為什么要使用 jsonb[]. 我試圖通過簡單地將 jsonb 對象數組從 jsonb 列復制到 jsonb[] 列來將數據插入到 jsonb[] 中。 但是出現錯誤“格式錯誤的數組文字:必須引入明確指定的數組維度”。

[
  {
    "SchoolsCode": "",
    "SchoolsName": "",
    "SchoolsType": "High School",
    "ErrorMessage": null,
    "SchoolsDegree": "Doctoral Degree",
    "BiskDocumentID": "",
    "FailedAttempts": 0,
    "SchoolsDegreeID": 2,
    "ChecklistsHidden": "Active",
    "ChecklistsStatus": "Received",
    "ChecklistsSection": "Official Transcript",
    "ChecklistsSubject": "High School Transcript (Bloomingdale High School)",
    "SchoolMailingAddress": {
      "City": "Windham",
      "Region": "ME",
      "Country": "United States",
      "ZipCode": "",
      "AddressStreet1": "406 Gray Rd",
      "AddressStreet2": null
    },
    "SchoolsConferredDate": "2018-05-01",
    "DocumentInformationID": 1,
    "SchoolsAttendedToDate": "2018-07-01",
    "SchoolsAttendedFromDate": "2014-04-01",
    "IsSalesforceUpsertSuccess": true,
    "IsStatusReceivedFromMaterialsEndpoint": true
  },
  {
    "SchoolsCode": "",
    "SchoolsName": "Bloomingdale High Scho",
    "SchoolsType": "High School",
    "ErrorMessage": null,
    "SchoolsDegree": "Doctoral Degree",
    "BiskDocumentID": "",
    "FailedAttempts": 0,
    "SchoolsDegreeID": 6,
    "ChecklistsHidden": "Active",
    "ChecklistsStatus": "Received",
    "ChecklistsSection": "Official Transcript",
    "ChecklistsSubject": "",
    "SchoolMailingAddress": {
      "City": "Windham",
      "Region": "ME",
      "Country": "United States",
      "ZipCode": "",
      "AddressStreet1": "406 Gray Rd",
      "AddressStreet2": null
    },
    "SchoolsConferredDate": "2018-05-01",
    "DocumentInformationID": 2,
    "SchoolsAttendedToDate": "2018-07-01",
    "SchoolsAttendedFromDate": "2014-04-01",
    "IsSalesforceUpsertSuccess": true,
    "IsStatusReceivedFromMaterialsEndpoint": true
  },
  {
    "SchoolsCode": "",
    "SchoolsName": "Governors State University",
    "SchoolsType": "High School",
    "ErrorMessage": null,
    "SchoolsDegree": "Bachelor's Degree",
    "BiskDocumentID": "fwafhawolef",
    "FailedAttempts": 0,
    "SchoolsDegreeID": 4,
    "ChecklistsHidden": "Active",
    "ChecklistsStatus": "Missing",
    "ChecklistsSection": "Official Transcript",
    "ChecklistsSubject": "High School Transcript (Bloomingdale High School)",
    "SchoolMailingAddress": {
      "City": "Windham",
      "Region": "ME",
      "Country": "United States",
      "ZipCode": "04062",
      "AddressStreet1": "406 Gray Rd",
      "AddressStreet2": null
    },
    "SchoolsConferredDate": "2018-05-01",
    "DocumentInformationID": 3,
    "SchoolsAttendedToDate": "2018-07-01",
    "SchoolsAttendedFromDate": "2014-04-01",
    "IsSalesforceUpsertSuccess": true,
    "IsStatusReceivedFromMaterialsEndpoint": true
  }
]

試試這個: inserting-jsonb-data-in-postgresql-9-6

文檔:該函數從 postgres 9.6 開始存在, funtions-jsonb-postgresql

簡單插入也應該有效。 例如:

 INSERT INTO orders (info)
    VALUES('{ "customer": "John Doe", "items": {"product": "Beer","qty": 6}}');

如果以上不起作用,請參閱此鏈接,此問題與您的類似: https : //stackoverflow.com/a/48866861/11094058

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM