Run SQL Queries

 

This section describes how to run SQL queries (SELECT or EXECUTE which display a result table) and display the result in a table view. If you want to run UPDATE, INSERT, DELETE, CREATE, DROP and other commands take a look at the "Run SQL Scripts" section.

 

SQL4X Manager J can save your queries from the SQL Viewer as double clickable query to your harddisk and export your query results (see below).

 

SQL Viewer

The SQL Viewer is designed to display query results. It displays all ANSI SQL 92 data types (including basic data types like VARCHAR, INTEGER or DATE and enhanced data types like BLOB, CLOB/TEXT, etc). The SQL Viewer actually executes your query and displays the result. You can either enter your query manually or use the SQL Query Assistant to generate a basic query.

 

Enter your SQL query manually

 

Start SQL Viewer

Open the SQL Viewer from the File menu, via shortcut (Command-L) or from the Database Information Panel.

Choose your database connection from the connection sheet. If you want to change your connection details for this query only click on the arrow. The connection details are displayed.

Click on "Connect" to establish the database connection.

The status line (between the query editor and the results table) displays "Status: Connected." after successfully connecting to the database server. Otherwise the error messages are displayed in the Message Viewer.

     
 

Enter your SQL query

Enter your SELECT or EXECUTE (for stored procedures) command in the query editor. The query editor supports syntax coloring and changes the color of every successfully recognized ANSI SQL92 command.

For a description of available commands and options take a look at your database vendors SQL documentation. SQL Viewer supports all special commands and functions of your database vendors.

     
 

Execute and display results

Click on "Run Query" in the toolbar or on the right side of the query editor to execute your query in preview mode. This means that not all available records are displayed. This speeds up the display of data from large tables. You can refine your query without having to transfer several MB of data every time. As soon as your query is completed click "Show All" in the toolbar to display all records from the result set.

The status line displays how long the database server needed to process the query and deliver the results. There is also a note that you are in preview mode.

You can change the number of records for preview mode and total result display with the Database Information Panel. Keep in mind that result processing and display is much faster if you use a small number of records to test your query.

 

Create SQL query with SQL Query Assistant

Instead of entering your SQL Query manually you can use the SQL Query Assistant to compose your SELECT command. The SQL Query Assistant is described here.

 

Create double-clickable queries

 

You can save your SQL query to your harddisk to be open by the SQL4X Viewer application. This feature is intended for web site administrator who want to take a look at some table contents on a regular basis (for instance member tables or transaction tables) or users with no SQL experience who need to export or process data from your database server.

With a double-clickable query you do not need to start up SQL4X Manager J and browse through the interface. The file includes all necessary connection information so the database connection is established, the query is executed and the result set is displayed.

     
 

Save your query

Click the "Save as double-clickable query" icon right of the query editor to display the save sheet.

If you want to include the password for your database connection in the query file check "Save password to double-clickable query file". This can cause some security concerns as the password is saved unencrypted. If you do not save the password the SQL4X Viewer application prompts for the password every time you run the query.

     
 

SQL4X Viewer application

The SQL4X Viewer application is a free utility you can redistribute to any number of users without paying a license fee. All features of the SQL4X Viewer included with SQL4X Manager J are available (except that you cannot modify the queries). This allows unexperienced users to view or export table data with your prepared queries.

To install the SQL4X Viewer application on another users desktop simply copy the SQL4X Viewer application in the users /Applications/ folder and the necessary JDBC driver in /Library/Java/Extensions.

SQL4X Manager J must be licensed for each system it is installed on. Only the SQL4X Viewer application is free.

 

Export query results

 

You can export your SQL query results to a variety of file formats. Please keep in mind that only the currently displayed results are exported. This means if you are displaying a preview only the records from your preview, not the full result set, is exported. Click "Show All" before running the export to make sure all records are included.

     
 

Exporting your query results

Click "Export" in the toolbar to display the export settings sheet and choose your export file format depending on the application you want to process the export. The following export file formats are available: CSV/Text, Tab-Delimited, HTML, XML.

The HTML format creates a HTML table with your data. The HTML table is formated with CSS (style sheets) so you can easily change text and color formating with your favorite HTML editor by changing the CSS styles.