Adding Dynamic column in existing column

Hello everyone, Hope all are doing good.

Currently we using cratedb version 4.2.6. I want to add extra dynamic object in existing column. Can any one help me about this.

E.g

CREATE TABLE IF NOT EXISTS "DB"."waypoint" (
   "info" OBJECT(DYNAMIC) AS (
      "alarmstate" OBJECT(DYNAMIC) AS (
         "boxstatus" TEXT,
         "ignstatus" TEXT,
         "msgpressed" TEXT,
         "txnreason" TEXT
      ),
      "assetInfo" OBJECT(DYNAMIC) AS (
         "assetStatus" TEXT,
         "assetid" TEXT,
         "assetname" TEXT,
         "hierarchyPath" TEXT,
         "plantId" TEXT,
         "plantName" TEXT,
         "transporterCode" TEXT,
         "transporterId" TEXT,
         "transporterName" TEXT
      ),
      "cellsite" OBJECT(DYNAMIC) AS (
         "currentcellid" TEXT,
         "lac" TEXT,
         "mcc" TEXT,
         "mnc" TEXT
      ),

Support I want to add time OBJECT (DYNAMIC) Under INFO column.
and in time object there are some extra column/object also there.

Thanks
Vinayak Katkar

Hi,
This can be done without issues, take a look at the example with name being added inside obj_column in Altering tables — CrateDB: Reference

1 Like

Hi,
But this will add new column , if i am not wrong,
I want to add dynamic column inside existing column.

Eg suppose

cellsite” OBJECT(DYNAMIC) AS (
         “currentcellid” TEXT,
          “lac” TEXT,
           Time Object(dynamic) as (
                waypoint1 text ,
                waypoint2 text,
)

Try

ALTER TABLE "DB"."waypoint"
   ADD COLUMN "info"['cellsite']['time'] OBJECT(DYNAMIC) AS (waypoint1 TEXT,waypoint2 TEXT);
3 Likes

Hi Hernanc,

Thanks alot for help. appreciated it. Its done.

Thanks
Vinayak Katkar