🛠️ This documentation is still under construction

Altering columns

Add column

We can add column description to table movies like this:

{
  "altertable": {
    "movies": {
      "addcolumn": {
        "description": {
          "type": "TEXT",
          "length": 1000
          "null": true
        }
      }    
    }
  }
}

Easily add multiple columns at once:

{
  "altertable": {
    "movies": {
      "addcolumn": {
        "description": {
          "type": "TEXT",
          "length": 1000
          "null": true
        },
        "release_date": {
          "type": "DATE"        
        }
      }    
    }
  }
}

Modify column

Modifying a column is done in generally the same way as adding one. The only difference is to put it in modifycolumn.

To modify the column you essentially have to recreate it, so all attributes must be specified, even if they don't change. If you wish, although discouraged, you can change this behaviour to only update specific attributes. Do this by setting recreate to false inside the column. This might seem convenient, but on a large version source it's very easy to lose track of what changes have been made to a column.

We can change the length of the column description on table movies like this:

{
  "altertable": {
    "movies" {
      "modifycolumn": {
        "description": {
          "type": "TEXT",
          "length": 200,
          "null": true
        }
      }
    }
  }
}

The only thing that will change is the column length. Just like with adding columns, we can easily modify multiple columns at once:

{
  "altertable": {
    "movies" {
      "modifycolumn": {
        "description": {
          "type": "TEXT",
          "length": 200,
          "null": true
        },
        "release_date": {
          "type": "DATE",
          "null": true
        }
      }
    }
  }
}

Rename column

We can simply rename the column description in table movies to synopsis like this:

{
  "altertable": {
    "movies": {
      "renamecolumn": {
        "description": "synopsis"
      }
    }
  } 
}

Drop column

Dropping (deleting) a column is done by providing an array of column names to the dropcolumn key.\

We can delete columns description and release_date from table movies like this:

{
  "altertable": {
    "movies": {
      "dropcolumn": ["description", "release_date"]
    }
  }
}