# Programming Derby-style table functions

Derby lets you create table functions. Table functions are functions which package up external data to look like Derby tables. The external data can be an XML file, a table in a foreign database, a live data feed--in short, any information source that can be presented as a JDBC ResultSet.

Derby-style table functions let you efficiently import foreign data into Derby tables. Table functions let you join Derby tables with any of the following data sources:

- XML-formatted reports and logs
- Queries that run in foreign databases
- Streaming data from sensors
- RSS feeds

See "CREATE FUNCTION statement" in the Java DB Reference Manual for the complete syntax needed to declare Derby-style table functions. The following topics provide information on how to write Java methods which wrap foreign data sources inside ResultSets.

- Overview of Derby-style table functions
  A Derby-style table function is a method which returns a JDBC ResultSet.
- Example Derby-style table function
  The following simple table function selects rows from a foreign database.
- Writing restricted table functions
  Restricted table functions are Derby-style table functions which perform more efficiently because they can be told in advance which columns they will be asked to fetch along with simple limits on those columns. This feature exploits the expressiveness of the Java programming language and does not require any extensions to SQL.
- Optimizer support for Derby-style table functions
  This topic explains how to fine-tune the Derby optimizer's decision about where to place a table function in the join order.

Parent topic: Derby server-side programming