Saturday, March 29, 2014

Getting at your data in your VM sample schemas

How can you get at your sample data?

Assumptions : You have your VM up and running.
http://datadowsingrod.blogspot.com/2014/03/where-to-begin.html
http://datadowsingrod.blogspot.com/2014/03/getting-your-vm-ready.html

For this discussion, I am going to keep my focus on the fairly new Database App Development VM machine.

No matter which of the three VMs you could have downloaded, they all come with SQL Developer. SQL Developer is a light weight IDE (Integrated Development Environment) that you can use to access you data.

If you want to know more about this tool, you can go right to the source!
http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html

When starting the VM, a terminal window (command window) will open up and tell you some key facts!



Notice that this machine has TWO databases! It has a database "instance" called "orcl" and a new one called "pdbl." In most other VMs that have databases, orcl has the sample data. In this one, pdbl has them.

What is "sample data" or "sample schemas?" Oracle provides sample data to use in their demonstration and training. More information on those can be found here - http://docs.oracle.com/cd/E16655_01/server.121/e15979/overview.htm#COMSC005 - but, suffice to say, it is good data to play with.

But to get to this data, you need to create "connections" in SQL Developer. Open up SQL Developer. On the left, you will see either no connections or just one for "pmuser"

Add caption


To really get control over these databases, we are going to create two connections to the SYSTEM user (a very powerful user) in each database. Click on the green Plus and fill in the blanks!


Some notes :
- The Connection Name can really be anything. I prefer to name them "database_schema." This is for the "orcl" database and for the "system" schema, so I called it "orcl_system"
- Password is "oracle"
- SID (meaning "Site IDentifier" is basically the name of the database - I know, that was pretty "rough!")


Some notes :
- Notice that I am using "Service Name" and not "SID" to specify the database "name" PDB1. I admit to know knowing WHY! "I am not a DBA, nor do I play one on TV.

Now you have two powerful connections!



Almost ready. Now you just need to find the sample schemas!

Example EACH system connections and then look for "Other Users"


In my opinion, you can get pretty far in life with the HR (Human Resources) and OE (Order Entry) schemas. These are in the PDB1_system connection so they are going to be in the PDB1 database. Create those connections as demoed below.



Now, your connects list should look like this -


Now you are ready to play! Expand (click on the "+") the PDB1_hr node and notice that a worksheet will open up. You are now ready to type your first command! I would suggest ...












SELECT *
FROM   employees;

Hit <Cntr+Enter> and sit back and bask in your accomplishments!
















No comments:

Post a Comment