Propagating database object changes
You can create or alter database objects by running DDL statements while connected to the grid and propagate the changes to all the servers in the grid.
About this task
You can propagate creating, altering, and dropping database objects to servers in the grid. For example, you can create a database or table or alter an existing database or table. You can also create stored procedures and user-defined routines.
You can choose to run the DDL statements on the local server and defer the propagation of the DDL statements to the other grid servers. Deferred propagation of DDL statements can be useful when you are rolling out schema changes or performing a rolling upgrade.
The grid must exist and you must run the grid routines as an authorized user from an authorized server.
Procedure
- Connect to the grid by running the ifx_grid_connect() procedure.
- Run one or more SQL DDL statements.
- Disconnect from the grid by running the ifx_grid_disconnect() procedure.
Results
If you deferred the propagation of DDL statements, you can propagate them by running the ifx_grid_release() function, or remove them by running the ifx_grid_remove() function.
Example
Suppose that you have a retail shop with a website. You replicate your data to several other locations for web applications. You want to be able to quickly and easily create, drop, and update tables. You create a grid named grid1, from which you can update the database schema for all servers in one step. The following example creates a table for special offers in the prod_db database:
Database prod_db;
EXECUTE PROCEDURE ifx_grid_connect('grid1');
CREATE TABLE special_offers(
offer_description varchar(255),
offer_startdate date,
offer_enddate date,
offer_rules lvarchar);
EXECUTE PROCEDURE ifx_grid_disconnect();