Previous Next JavaScript must be enabled to correctly display this content

## Add or Remove an MR_COUNTER column

You can alter an existing multi-region table to add an MR_COUNTER column. The existing records in the table will have a value of zero for the newly added MR_COUNTER column. You can also remove an existing MR_COUNTER column from a multi-region table.

Example 5-45 Add an MR_COUNTER column to an existing multi-region table

Use ALTER TABLE to add an MR_COUNTER column to an existing multi-region table.

Create a multi-region table `myTable` without an MR_COUNTER column.

    CREATE TABLE myTable ( id INTEGER,
                         name STRING,
                         team STRING,
                         PRIMARY KEY (id)) IN REGIONS DEN,LON

Use ALTER TABLE to add an MR_COUNTER column to the table myTable. This is a PN counter.

`ALTER TABLE myTable (ADD count INTEGER AS MR_COUNTER);`

You can use ALTER TABLE to add a JSON MR_COUNTER field to a multi-region table.

    ALTER TABLE demoJSONMR ADD (secondJSON
              JSON(new_counter AS NUMBER MR_COUNTER))

Example 5-46 Drop an MR_COUNTER column

To remove an MR_COUNTER column from a multi-region table, use ALTER TABLE statement with a DROP id clause.

    CREATE Table myTable( name STRING,
                          count INTEGER AS MR_COUNTER,
                          PRIMARY KEY(name)) IN REGIONS DEN,LON

    ALTER TABLE myTable (DROP count)

You can also drop a JSON column containing MR_COUNTERS from a table using ALTER TABLE syntax.

    ALTER TABLE demoJSONMR(DROP secondJSON)