Oracle SQL Tutorial 9 – Intro to Queries

Video ready, click here to close ×


This video is for beginners who have never worked with SQL Developer, and we are going to teach how to begin writing queries. So the queries we are going to start with are queries when we give the database an expression and it will return back some kind of value.

The most common keyword you are going to need to know for Oracle is SELECT. SELECT is the command we use to get data from the database. Even though we have not really put any data in our database, we can still use the SELECT statement to get data. That’s because the database is capable of doing more than just creating tables and retrieving data from tables.

So our first goal is to essentially write a Hello World, which just displays the text hello world to us.

A good place to start is with:

SELECT ‘Hello World’

This would actually work for many database management systems, but when you run it you will get an error. This actually doesn’t work with Oracle, it will tell us we always need the FROM keyword. To get around this, there is a magical table called DUAL. We can put anything we want to SELECT and then say FROM DUAL and it will work.

SELECT ‘Hello World’ FROM DUAL

We can also do math:

SELECT 1+1 FROM DUAL

And we can run even run functions:

SELECT SYSTIMESTAMP FROM DUAL

To put all of this together, you can grab all of this data at the same time using commas to separate different columns from our generated table:

SELECT ‘Hello World’, 1+1, SYSTIMESTAMP FROM DUAL

Support me on Patreon: http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

source

3 comments

Leave a Reply

Your email address will not be published. Required fields are marked *