Skip to main content

ALTER BLOCKCHAIN (bSQL) | Blockpoint Docs

Modifies the current schema of a specified blockchain. For examples, see Examples.

bSQL Syntax Conventions

Syntax​

ALTER BLOCKCHAIN { database_name.blockchain_name | blockchain_name }
{
ALTER COLUMN column_name <column_definition>
| ADD COLUMN <column_definition>
| DELETE COLUMN column_name
}

Full Syntax​

<column_definition> ::= (
{column_name <data_type>}
[ PACKED [= <bool>] | PADDED [= <bool>]]
[ NULLABLE [= <bool>] ]
[ DEFAULT VALUE = default_value ]
[ ENCRYPT = "key_name" ]
[ TRACK VALIDITY = '['"key_name" , validity_level']']
[ <column_constraint> [, ...n ] ]
[ CHECK '['logical_expression']']
[ COMPUTED '['computed_expression']']
)

Arguments​

database_name
The name of the database in which the blockchain was created.

blockchain_name
The name of the blockchain to be altered. If the blockchain isn't in the current database, you must explicitly specify the database.

ALTER COLUMN
Specifies that the named column is to be changed or altered.

The modified column can't be:

  • A column with a timestamp data type.

    [!NOTE] Statistics that are automatically generated by the query optimizer are automatically dropped by ALTER COLUMN.

  • Used in a PRIMARY KEY, FOREIGN KEY, or HISTORICAL REFERENCE constraint.

  • Has an index on it.

column_name
The name of the column to be altered, added, or dropped.

column_definition The new column to be added to the blockchain in case of an "ADD_COLUMN" command. Or the modified column definition for column_name in the case of an "ALTER COLUMN" command.

ADD COLUMN
Specifies that the new column to be added to the blockchain.

The additional column:

  • Must have a DEFAULT VALUE specified, or be a NULLABLE field unless the blockchain contains no data.
  • Can't be a PRIMARY KEY, FOREIGN KEY, or HISTORICAL REFERENCE.
  • Is appended to the end of the blockchain.

DELETE COLUMN
Specifies the column to dropped from the blockchain.

The deleted column can't be:

  • A primary key or foreign key.

Permissions​

ALTER permissions required on the target blockchain.

ALTER permissions on a blockchain container default to members of the admin fixed database role. Members of the admin role can transfer permissions to other users.

Examples​

Basic Syntax​

Examples in this section demonstrate the basic functionality of the ALTER BLOCKCHAIN statement using the minimum required syntax.

A. Modifying a Column​

The following example alters the column named price to be of type float64 blockchain.

ALTER BLOCKCHAIN financial.pricing  
ALTER COLUMN price (price FLOAT64)

B. Adding a Column​

The following example adds the column named profitable.

ALTER BLOCKCHAIN financial.companies  
ADD COLUMN (profitable BOOL NULLABLE = TRUE)

C. Deleting a Column​

The following example deletes the column named 52_week_high.

ALTER BLOCKCHAIN 
DELETE COLUMN 52_week_high

See Also​