# Executing SQL statements in RadRails [edit]

This page describes how to execute SQL statements in RadRails.

## Introduction

RadRails provides you with two ways to execute SQL statements. You can use the Data Perspective and write statements in the Query View, or you can execute SQL statements in files with a .sql file extension from the Rails Navigator View in the RadRails perspective. The instructions below explain how to execute SQL statements using either method.

## Instructions

### Executing SQL statements from the Data Perspective

After you have set up your database (see Browsing a database in RadRails), you can execute SQL statements against your database in the Data Perspective.

To execute SQL statements from the Data Perspective:

1. In the upper right corner of your workbench, click the button to switch to the Data Perspective.
2. In the text box in the Query View, type your SQL statement (e.g. a SELECT statement).
3. Click the Execute button.

RadRails executes your SQL statement and displays the results in the Result View.

### Executing SQL statements from the Rails Navigator View

To execute SQL statements form the Rails Navigator View:

1. If you are not in the Rails Perspective, click the button in the upper right corner of your workbench to switch.
2. In the Rails Navigator View, expand the folder containing your Rails project.
3. Navigate to and right-click the .sql file that you want to execute, then select Execute SQL and a database from the context menu.

RadRails executes the entire contents of the .sql file and displays the success or failure of the action, including corresponding error messages, if any.

## Related Topics

- Getting started with RadRails
- Starting a new RadRails project
- Importing an existing project into RadRails
- Building an application in RadRails
- Running a unit test on RadRails
- Creating and running a WEBrick server
- Browsing a database in RadRails
- Using a Mongrel server

Retrieved from "http://aptana.com/docs/index.php/Executing_SQL_statements_in_RadRails"

Categories: AptanaHelp | RadRails