# Using SQL Explorer [edit]

This page explains how to use the SQL Explorer plug-in with RadRails.

## Introduction

This Help topic will teach you how to use SQL Explorer with RadRails after you have connected to your database. This is the final step in configuring SQL Explorer to work with RadRails. You will need to connect to your database before following the instructions below.

Note: This Help topic is based on the Rolling with Ruby on Rails tutorial from ONLamp:

http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1

## Instructions

This section explains how to do some of the most common tasks that you will perform in SQL Explorer.

### Creating a new database

To create a new database in SQL Explorer, paste the SQL below into the SQL editor and click the Execute button:

    CREATE DATABASE cookbook;

### Creating a new table

To create a new database table in SQL Explorer, paste the following SQL into your SQL Editor and click the Execute button:

    CREATE TABLE `recipes` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `title` varchar(255) NOT NULL,
      `instructions` text NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

### Inserting data into a table

To insert data into a database table in SQL Explorer, paste the following SQL code into your SQL Editor and click the Execute button:

    INSERT INTO `recipes`
      (title, instructions)
    VALUES
      ('test', 'this is a test record');

### Querying a table

To query a database table, paste the following SQL code into your SQL Editor and click the Execute button:

    SELECT *
      FROM `recipes`;

Additionally, you can use a generated SELECT statement to query a table. To generate a SELECT statement:

1. In the Database Structure View, navigate to the table that you want to query.
2. Right-click the table that you want to query, and select Generate Select Statement from the context menu.

SQL Explorer generates the SELECT statement for you.

### Additional resources

The following list includes additional links for SQL Explorer documentation:

- SQL Explorer web site - http://www.sqlexplorer.org/features.php
- SQL Explorer Documentation - http://www.sqlexplorer.org/sqleditor.php
- MySQL 5.1 Reference - http://dev.mysql.com/doc/refman/5.1/en/index.html
- Configuring SQLExplorer Access - http://www.onjava.com/pub/a/onjava/2005/05/11/sqlexplorer.html?page=2

## Related Topics

- Configuring the Eclipse SQL Explorer plug-in for RadRails
- Installing the SQL Explorer plug-in
- Deploying ConnectorJ
- Creating a new driver in Eclipse
- Creating a new connection in SQL Explorer
- Connecting to the database application

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

Categories: AptanaHelp | RadRails