Aptana Studioヘルプ > はじめに > Developing Rails Projects with RadRails > Configuring the Eclipse SQL Explorer plug-in for RadRails

Using SQL Explorer

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

Contents

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:

Related Topics