Forum Stats

  • 3,769,395 Users
  • 2,252,961 Discussions
  • 7,875,018 Comments

Discussions

Creating table with json data

User_A8XLF
User_A8XLF Member Posts: 10 Employee
edited Feb 4, 2021 8:56AM in SQL & PL/SQL

Hi ,

I am creating a SQL table with JSON data in it. I wote the following SQL script-:

CREATE TABLE json_documents (

 id  NUMBER,

 data CLOB,

 CONSTRAINT json_documents_pk PRIMARY KEY (id),

 CONSTRAINT json_documents_json_chk CHECK (data IS JSON)

);

INSERT INTO json_documents (id, data)

VALUES (1, '{

   “userId”:[email protected],

   “priviliges”:[

     {

      “name”:"A",

      “code”:"1",

     },

     {

      “name”:"B",

      “code”:"2",

     },

{

      “name”:"C",

      “code”:"3",

     },

 {

      “name”:"D",

      “code”:"4",

     },

 {

      “name”:"E",

      “code”:"5",

     },  

{

      “name”:"F",

      “code”:”6”,

     }

    ]

}');

COMMIT;

The issue is the table gets created but no data is inserted into it. When i run the select command it returns "No rows were selected". Please help.

Tagged:

Best Answer

Answers