Skip to Main Content

NoSQL Database

Announcement

Testing banner

how to reference a nested field when the admin want to add a new field within the existing field

Eric JingDec 16 2022

Dear sir,
I'm making some test on oracelnosql, and I have a table like this:
CREATE TABLE if not exists companyTable
(
companyid integer,
teams map(array(userid integer, firstname string, lastname string))
primary key (companyid)
)
And, above table already created in my oracelnosql db.
Now, I want to add one more sub field within the nested field teams, to make the table finally look like this:
CREATE TABLE if not exists companyTable
(
companyid integer,
teams map(array(userid integer, firstname string, lastname string, salary integer))
primary key (companyid)
)
So, how can I reference the nested field? I have tried several times but I field:
alter table companytable (add teams.values().salary); //failed
alter table companytable (add teams.values()[].salary); //failed

If I cannot update the table definition, it means I have to delete the table along with the data and create the companytable again, which means db data is removed during maintaince(impossible in real life).
Could you give me some tips of how to reference above nested field to add the sub field "salary"? Thank you so much.

Comments
Post Details
Added on Dec 16 2022
9 comments
53 views