1

How to open a SQL scrap book in eclipse

[Social9_Share type="horizontal"]

Opening SQL Scrapbook in Eclipse

Whenever you are working with database applications in eclipse, you might want to open, view and query the database. To do this, you need not open the sql command line. Instead you can connect to the database and view the tables from eclipse. You can open a SQL Scrapbook similar to sql command line where you can query the tables from inside eclipse.

Now, let’s query the table and execute some sql queries from eclipse directly.

To open the SQL Scrapbook, click Window -> show view -> select Data Source Explorer .Select SQL Scrapbook icon from the right corner of Data Source Explorer.

sql1 

Your SQL Scrapbook opens now.

sql2 

Select the db Type (For me its oracle 10g) .Once you select this, under Name you get the list of names available for the type. Then select the Database. Since I am using oracle, I get the option as xe.

sql3 

Once you have selected all the three properly, the Status shows as connected.

The next step is to write the query. I am writing the query as select * from STUDENT. To run this right click inside the window and select Execute Current Text or Alt + S.

sql4 

Now, come back to Data Source Explorer Tab. Click on SQL Results tab. Click Results. You can see the results of your query.

sql5 

Let’s try one more example.
We will try to insert values into a table.I will write the query as INSERT INTO STUDENT VALUES(‘JOEY’,18,’BANGALORE’);. To run this, select the query, right click inside the window and select Execute Selected Text .

sql6 

Now, come back to Data Source Explorer Tab. Click on SQL Results tab. Click Results. You can see the status as inserted.

sql7 

To view the table, click Data Source Explorer Tab. select the schema, then select your table-> right click ->Data ->Edit.

sql8 

The table is opened now. Select F5 or right click and select Refresh.

sql9

You can see the values inserted in the table.

Thats all.
Happy Learning

Post a comment