#### Tables/Views

Tables and views are mapped objects of the tables and views in the raw database that a connection refers to. Mapped objects have mapped names that can be different from their names in the raw database. A catalog stores information about the real tables/views mapped, such as the name, qualifier, and owner.

Since tables/views are only mapped objects, they can be mapped and then re-mapped. That is, the information of the real tables/views stored in a catalog is changeable. This is useful when you are off-line from your database. You will still be able to see the table structure and generate reports. In addition, when changing the connection, for example, from an Access database to an Interbase, you will only need to re-map all the tables/views in the catalog as opposed to creating a new catalog.

##### Adding tables/views to a catalog

To add tables stored in the database to a catalog via the JDBC connection you set up, take the following steps:

1. In the Data tab of the Catalog Browser, right-click the Tables node of the JDBC connection, then select Add Table from the shortcut menu. The Add Table dialog displays. See the dialog.

2. If the database supports schema, check and select a schema from the Schemas box.

   Note: If you have selected schemas in the Schema tab of the Get JDBC Connection Information dialog when setting up the connection, only the selected schemas will be listed in the Schemas box by default, however, you can check the Show All Schemas option to show all the schemas in the database.

3. Click the Load Tables button. The tables contained in the selected schema will then be displayed in the Tables box.
4. Check the Include System Tables option if you want to have the system tables available in the Tables box.
5. Check Include Added Table to make the tables that have been added to the connection available in the Tables box.
6. Choose the required tables in the Tables box, and then click Add.

   To choose consecutive tables, click the first table, press and hold down Shift, and then click the last table. To choose tables that are not consecutive, press and hold down Ctrl, and then click each table.

7. Repeat steps 3 and 4 to add tables from other schemas.
8. To add certain tables by name or by patterns in their name, select the Table Name Pattern checkbox. The wildcard % will then be displayed in the text box.

   For example, if you want to add tables beginning with AL, you can type AL% (case sensitive) in the text box, and click the Load Tables button. All the tables beginning with AL in the selected schema will then be displayed in the Tables box. Choose the tables that are required by clicking Add. They will then be added to the connection.

9. After adding the required tables, click Done to close the dialog.

Notes:

- When you have added some tables to a catalog, you can then set up pre-joins between them. For detailed information, see the chapter Pre-joins.
- In the Add Table dialog, if the Include Added Table option is checked, when you click the Add button to add a table that has already been added to the connection once, the Input Table Name dialog will be displayed, prompting you to give the new table a different name.
- To add views, right-click on Views in the Connection node, and then on the shortcut menu, click Add View. The Add View dialog will then be displayed.

##### Refreshing tables/views

The tables/views in your catalog are a temporary deposit to improve the performance when you design and test your report. Your database keeps changing over the time. However, these will not be reflected automatically in your catalog. To synchronize your tables/views in the connection and database, you can choose to refresh the table/view information using the Refresh command on the shortcut menu of the table/view. Then when the refreshing job is done, a reporting dialog will be shown, summarizing the changes and operations that have been taken.

##### Inserting columns to tables/views

By default, when you add a table/view, you add all the columns reside in the table/view. However, JReport gives you the flexibility to remove columns in a table/view, leaving only the columns useful to your reports. Additionally, your database keeps changing over the time. You can add the columns to the table after you delete them or the database has been updated.

To add columns to a table/view:

1. Right-click the table/view to which you want to insert the column, then select Insert Column from the shortcut menu.
2. In the Add Column dialog, select the required columns from the Columns box.

   There will be no available column in the Columns box if you do not delete any in the table/view before, or no update has been made to the database. That is to say, you cannot add columns that do not belong to the table/view.

3. Click the Done button to add the columns to the table/view.

Tip: If you want to add all the columns in a table/view at a time, you can also choose to refresh the table/view, which synchronizes the table/view in catalog with the one in your database.

##### Previewing the column data of tables/views

In the Catalog Browser, you can preview the data for a database column, which enables you to have a general idea about the field contents, field type, and other useful information related to this field.

To preview the data of a column:

1. Right-click the column with the data you want to preview, then on the shortcut menu, click Browse Data.
2. The data of this column is shown in a list in a dialog, which also includes other information including the field type, precision, scale and number of records.

##### Organizing tables/views

You can organize the tables/views, which have been added to a catalog via a JDBC connection, by arranging them in different folders in the Catalog Browser.

To add a folder:

1. Right the Tables/Views node (or any existing folder) and select Add Folder from the shortcut menu.
2. A new folder is added to the Tables/Views node. Type a name for the folder in the editing area, and then click outside to confirm the change.

To move tables/views to a folder:

1. Right-click the table/view you want to move in the Tables/Views node and select Move To from the shortcut menu.
2. In the Move Table/View dialog, select the folder to which the table/view will be moved, then click OK.