content_image/710049.jpg
## 16.8 The FEDERATED Storage Engine 

## The FEDERATED Storage Engine 

The FEDERATED  storage engine lets you access data from a remote MySQL database without using replication or cluster technology. Querying a local FEDERATED  table automatically pulls the data from the remote (federated) tables. No data is stored on the local tables. 

To include the FEDERATED  storage engine if you build MySQL from source, invoke CMake  with the - DWITH_FEDERATED_STORAGE_ENGINE  option. 

The FEDERATED  storage engine is not enabled by default in the running server; to enable FEDERATED , you must start the MySQL server binary using the --federated  option. 

To examine the source for the FEDERATED  engine, look in the storage/federated  directory of a MySQL source distribution. 

## 16.8.1 FEDERATED Storage Engine Overview 

When you create a table using one of the standard storage engines (such as MyISAM , CSV  or InnoDB ), the table consists of the table definition and the associated data. When you create a FEDERATED  table, the table definition is the same, but the physical storage of the data is handled on a remote server. 

## A FEDERATED  table consists of two elements: 

•A remote server  with a database table, which in turn consists of the table definition (stored in the MySQL data dictionary) and the associated table. The table type of the remote table may be any type supported by the remote mysqld  server, including MyISAM  or InnoDB . 

•A local server  with a database table, where the table definition matches that of the corresponding table on the remote server. The table definition is stored in the data dictionary. There is no data file on the local server. Instead, the table definition includes a connection string that points to the remote table. 

When executing queries and statements on a FEDERATED  table on the local server, the operations that would normally insert, update or delete information from a local data file are instead sent to the remote server for execution, where they update the data file on the remote server or return matching rows from the remote server. 

The basic structure of a FEDERATED  table setup is shown in Figure 16.2, “FEDERATED Table Structure” . 

<img src='content_image/710049.jpg'>

