Getting Started with IntelliJ IDEA by 2013

Getting Started with IntelliJ IDEA by 2013

Author:2013
Language: eng
Format: epub
Publisher: Packt Publishing


As we have lot of things to do, you can use the files available in this book to load the data in our database. Click on the File menu and choose Open...; in the dialog that appears, select the file email.sql and click on the OK button. The file will be opened in a new tab. You will notice that at the top of the tab is a yellow bar asking about the SQL dialect; click on the link at the right called Change dialect to.... In the SQL Dialects window, select the line project and click on the cell in the column SQL Dialect. A list of available dialects will appear, so, select MySQL and press the OK button.

You've probably noticed that this file wasn't opened in the query console and that there isn't any button available to execute the script. Differently from the query console, when you open a SQL script directly with IntelliJ, you don't need to put the cursor over a line you want to execute; the whole script will be executed, and that is what we want. To execute it, right-click anywhere in the script and select Run "email.sql"; now, if you use the Refresh button in the table editor in the person table, you will see that the data was inserted into the table. Now you can do the same for phone.sql and person.sql files.

Once the data is loaded in all the tables, we can work with them; so, if it isn't open, open the person table in the table editor. As you can see, some data is loaded by default, but this is limited to 52 records—you can see this when you click on the Query button. Despite being a tool that will sometimes help you, the table editor doesn't permit changes in the query used to retrieve data and doesn't have some visual facilities that are available in tools like Microsoft Access; so, if you want to see two or more tables together, you need to write the query in a query console.

We will now create a simple database view that permits us to see the data from the person table joined with the data from the e-mail table; so, open the query console and type the following query:

create view person_and_email as select person_id,email.id as email_id, complete_name, birth_date, place_of_birth, email from person left join email on person.id=email.person_id



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.