Execute an SQL File

To execute an SQL file from NetBeans you first need to open it in the editor pane. A widget that appears at the top of the editor pane can be used to execute its sql statements.

In the "Services" pane you can also view a list of tables in a database. The data in the tables can be viewed with a menu selection that executes a NetBeans-generated SQL command.

Open the SQL File

The file opened in this example is included in the database project. You could also open files using the "OpenFile…" menu item in the NetBeans "File" menu. This gives you access to your entire file system.

Run the SQL File

Make sure the appropriate connection is selected in the "Connection:" combobox. Then click on the "Run SQL" button.

View a Database Table

A database table can be viewed by right-clicking on the table in the services pane and selecting "View Data…" You may need to expand the tree node for the connection as shown. The results appear in the editor pane.

Results

The editor pane shows the SQL command used for obtaining the table data. A new pane below the editor pane shows the table data.