10bet网址
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 36.3Mb
PDF (A4)- 36.3Mb
Man Pages (TGZ)- 235.3Kb
Man Pages (Zip)- 347.1Kb
Info (Gzip)- 3.3Mb
Info (Zip)- 3.3Mb
Excerpts from this Manual

15.8.1 FEDERATED Storage Engine Overview

When you create a table using one of the standard storage engines (such asMyISAM,CSVorInnoDB), the table consists of the table definition and the associated data. When you create aFEDERATEDtable, the table definition is the same, but the physical storage of the data is handled on a remote server.

AFEDERATEDtable consists of two elements:

  • Aremote serverwith a database table, which in turn consists of the table definition (stored in the.frmfile) and the associated table. The table type of the remote table may be any type supported by the remotemysqldserver, includingMyISAMorInnoDB.

  • Alocal serverwith a database table, where the table definition matches that of the corresponding table on the remote server. The table definition is stored within the.frmfile. However, 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 aFEDERATEDtable 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 aFEDERATEDtable setup is shown in图15.2。”FEDERATED Table Structure”.

Figure 15.2 FEDERATED Table Structure

Content is described in the surrounding text.

When a client issues an SQL statement that refers to aFEDERATEDtable, the flow of information between the local server (where the SQL statement is executed) and the remote server (where the data is physically stored) is as follows:

  1. The storage engine looks through each column that theFEDERATEDtable has and constructs an appropriate SQL statement that refers to the remote table.

  2. The statement is sent to the remote server using the MySQL client API.

  3. The remote server processes the statement and the local server retrieves any result that the statement produces (an affected-rows count or a result set).

  4. If the statement produces a result set, each column is converted to internal storage engine format that theFEDERATEDengine expects and can use to display the result to the client that issued the original statement.

The local server communicates with the remote server using MySQL client C API functions. It invokesmysql_real_query()to send the statement. To read a result set, it usesmysql_store_result()and fetches rows one at a time usingmysql_fetch_row().