Oracle SQL Tutorial 9 - Intro to Queries

Sharing buttons:

hey guys welcome back this video is

going to be an introduction to queries

and I apologize ahead of time if my

audio is not the best I'm in the process

of kind of setting up a studio so I

don't have all my equipment set up right

now and this is the best I can do for

now so hopefully it's okay for you guys

I think we'll be able to get through it

so let's dive right in I'm an Oracle SQL

developer which is the app we use to

connect and communicate to our Oracle

database and I have my subscribed

database open now if your window layout

looks any different than mine you can

always go up to here to window and then

reset window to factory settings so what

is a query exactly well a query is how

we get data from a database and

literally people can have an entire

career just from writing queries so this

topic is stinking huge but we're going

to start with the very basics in fact

we're not even going to get data from a

table we're just going to start with

what's known as expressions expressions

are these things that can be evaluated

to something so think back to like math

class you might have something like five

plus five oh my goodness let's try this

again so you might have something like

five plus five and that can be evaluated

to ten so this right here this is an

example of an expression but we can also

have expressions with other things such

as strings

so that is a string in fact we're going

to put hello world and essentially we're

going to try to create a hello world

program which is basically the first

program you usually try to write when

you start a programming language just so

you can get it set up type something

small and get it running so that's what

we're going to do it's going to be a

little bit different than other

programming languages because this is a

database but the end result is going to

be pretty similar so how do we go about

telling the database that we want it to

tell us hello world right now we're

telling it hello world but we want it to

respond well the way we get data from a

database is using what's known as the

Select keyword and that's going to go at

the beginning of your query so now we're

saying select this string and it should

give us the data back

but not quite there's a little thing we

have to do and I'll explain that in a


but in most database management systems

this right here would work but let's run

it and see what happens

you can run it by pressing this button

here or pressing f5 and you can see we

get an error and it's basically saying

that it requires the from keyword so

where do we put the from keyword it's

actually right after the expression so

we put it right here and what do we take

this data from well Oracle has this

magical table it's called dual and this

is going to allow us to basically do

this but in Oracle so when we do this

it's going to respond with hello world

so let's run it and see how it works and

you can see the output right here hello

world so works

you guys just created your first hello

world application it's very very simple

now I ain't trying to make Oracle sound

much simpler than it is Oracle is like a

beast it can do anything in fact it can

even do addition so instead of putting a

string here we can pass in some addition

let's run this there we go

5 plus 5 equals 10 you can also throw

things in here known as functions so a

good one we can try is assists timestamp

let's try that and you can see it gives

us the exact time of our machine so

that's pretty sweet when you're working

with select statements and tables

usually you're going to want to have

multiple columns so in this situation

all we're doing is selecting one thing

but I want to select multiple things so

the way you do that is you just add a

comma and then you say the next thing

you want to grab so we could throw in a

string here say hello world and then we

could throw in another comma and we'll

actually do another math problem let's

go 5 times 5 now the last one does not

require a comma so you can keep it that

way let's try this and see if it works

so we basically have a generated table

here are the column headers

and here are the values although we only

scratched the bare surface of the select

statement I think that's a good place to

end for now and in the next video we'll

begin to setting this and learning a

little bit more about how we structure

our SQL so thanks guys please be sure to

subscribe I really appreciate that and

if you like this video please click like

and I will see you in the next video

peace you thought I wasn't going to say