All language subtitles for [SubtitleTools.com] Select - Learning Oracle 12c [Video]

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,400 --> 00:00:04,550 In this lesson, we're going to take a look at what is probably 2 00:00:04,550 --> 00:00:08,750 the most important statement in the SQL programming language, 3 00:00:08,750 --> 00:00:10,730 and that is select. 4 00:00:10,730 --> 00:00:12,500 So let's start SQL Developer. 5 00:00:15,290 --> 00:00:17,550 That was our tip of the day. 6 00:00:17,550 --> 00:00:20,520 And we're going to connect to the ORCL Database 7 00:00:20,520 --> 00:00:22,080 using the scott user-- 8 00:00:22,080 --> 00:00:24,430 using these connections we've set up. 9 00:00:24,430 --> 00:00:29,720 I'm just going to click the plus next to scott_orcl, 10 00:00:29,720 --> 00:00:33,500 and now we have our worksheet, here, to type in SQL commands 11 00:00:33,500 --> 00:00:36,500 and see the result. I also wanted to point out, here, 12 00:00:36,500 --> 00:00:42,170 in SQL Developer that if we click the plus besides Tables, 13 00:00:42,170 --> 00:00:44,110 we'll get a list of all of the tables 14 00:00:44,110 --> 00:00:46,390 that are owned by the scott user. 15 00:00:46,390 --> 00:00:49,450 So our connection is using the scott user 16 00:00:49,450 --> 00:00:53,330 to connect into the database, and these are the tables 17 00:00:53,330 --> 00:00:56,830 that Scott owns-- the scott user. 18 00:00:56,830 --> 00:00:59,290 So when we use a select statement, 19 00:00:59,290 --> 00:01:02,480 we have a certain format that we will use. 20 00:01:02,480 --> 00:01:05,230 Let's start with the basic format 21 00:01:05,230 --> 00:01:08,630 and go more advanced as we go along. 22 00:01:08,630 --> 00:01:14,790 So let's do a select * from emp. 23 00:01:14,790 --> 00:01:19,120 EMP is one of the tables that we have here, 24 00:01:19,120 --> 00:01:22,660 and we're going to type in a select * from EMP. 25 00:01:22,660 --> 00:01:24,680 Notice that we end with a semicolon. 26 00:01:24,680 --> 00:01:29,350 So the semicolon is what we call a statement terminator in SQL. 27 00:01:29,350 --> 00:01:36,870 Also notice that whitespace is ignored in the SQL programming 28 00:01:36,870 --> 00:01:37,650 language. 29 00:01:37,650 --> 00:01:41,910 So it doesn't matter if we have this on multiple lines or one 30 00:01:41,910 --> 00:01:50,310 line, or even a line, almost, for every statement or clause. 31 00:01:50,310 --> 00:01:52,320 Either way, it'll execute the same way. 32 00:01:52,320 --> 00:01:53,820 So whitespace is ignored, and that's 33 00:01:53,820 --> 00:01:55,830 what the importance of that statement terminator 34 00:01:55,830 --> 00:01:58,530 is, because it's free to ignore whitespace 35 00:01:58,530 --> 00:02:01,980 because it knows it has to read the command until the statement 36 00:02:01,980 --> 00:02:03,150 terminator. 37 00:02:03,150 --> 00:02:06,600 When we want to execute a statement in SQL Developer, 38 00:02:06,600 --> 00:02:10,970 we click the green arrow, or Run Statement. 39 00:02:10,970 --> 00:02:14,330 Let's look at what we have here. 40 00:02:14,330 --> 00:02:18,290 When we executed select * from the EMP table, 41 00:02:18,290 --> 00:02:21,860 it's showing us all of the columns and all of the rows 42 00:02:21,860 --> 00:02:22,890 in the EMP table. 43 00:02:22,890 --> 00:02:25,250 So we have columns like EMPNO and ENAME 44 00:02:25,250 --> 00:02:28,860 and JOB, and then all of the different rows. 45 00:02:28,860 --> 00:02:33,260 Notice that this is the table itself, or the table data. 46 00:02:33,260 --> 00:02:37,280 This column here is actually provided by SQL Developer just 47 00:02:37,280 --> 00:02:38,660 to show line numbers. 48 00:02:38,660 --> 00:02:41,720 So you see there's no column name here. 49 00:02:41,720 --> 00:02:44,270 So we always keep that in mind, but those are just line 50 00:02:44,270 --> 00:02:46,890 numbers, and they're not data. 51 00:02:46,890 --> 00:02:50,260 So select * from EMP gives us this data. 52 00:02:50,260 --> 00:02:51,970 So the format of a select statement 53 00:02:51,970 --> 00:02:56,350 will be select, and then either a * or column name, 54 00:02:56,350 --> 00:02:57,520 and then a from. 55 00:02:57,520 --> 00:03:02,440 So the simplest form of select statement has select and from. 56 00:03:02,440 --> 00:03:05,170 But what if we don't need all of the columns, 57 00:03:05,170 --> 00:03:07,420 we only want one column? 58 00:03:07,420 --> 00:03:13,960 Then we change this to select ename from emp. 59 00:03:13,960 --> 00:03:16,750 These commands that pop up here are just helper commands 60 00:03:16,750 --> 00:03:18,160 from SQL Developer. 61 00:03:18,160 --> 00:03:19,120 We can ignore those. 62 00:03:19,120 --> 00:03:22,560 And we click our green arrow again, 63 00:03:22,560 --> 00:03:26,670 and it presents us with this column-- the ENAME column-- 64 00:03:26,670 --> 00:03:29,290 and no other data besides that. 65 00:03:29,290 --> 00:03:32,910 We can also do multiple columns-- 66 00:03:32,910 --> 00:03:33,860 ENAME and JOB. 67 00:03:36,520 --> 00:03:38,690 We get the employee and the job. 68 00:03:38,690 --> 00:03:42,800 These correspond as if we had brought all the data back. 69 00:03:42,800 --> 00:03:44,570 The ENAME SMITH goes with CLERK. 70 00:03:44,570 --> 00:03:49,790 ENAME ALLEN goes with SALESMEN, so on and so forth. 71 00:03:49,790 --> 00:03:51,030 Let's go back to *. 72 00:03:53,630 --> 00:03:57,250 Now, we just did what's called column restriction. 73 00:03:57,250 --> 00:04:00,550 So we restricted the data we brought back based on column. 74 00:04:00,550 --> 00:04:04,150 We can also restrict data based on rows. 75 00:04:04,150 --> 00:04:07,170 And to do that, we need a condition. 76 00:04:07,170 --> 00:04:09,460 Here we use a where clause. 77 00:04:09,460 --> 00:04:16,430 So we'll say where ENAME = single quotes-- 78 00:04:16,430 --> 00:04:17,990 let's change this to job. 79 00:04:17,990 --> 00:04:19,820 It will show us more data. 80 00:04:19,820 --> 00:04:21,110 job = 'SALESMAN.' 81 00:04:25,810 --> 00:04:28,110 And execute. 82 00:04:28,110 --> 00:04:31,620 So this gives us the data on all the salespeople 83 00:04:31,620 --> 00:04:34,250 that we have in this table. 84 00:04:34,250 --> 00:04:37,550 Now, notice that we have single quotes around salesman, 85 00:04:37,550 --> 00:04:42,830 and within single quotes, case and whitespace are preserved. 86 00:04:42,830 --> 00:04:45,560 So even though we can type our statements 87 00:04:45,560 --> 00:04:49,190 either uppercase or lowercase, in the statement itself, 88 00:04:49,190 --> 00:04:53,900 if we're in single quotes, then we have to respect the case. 89 00:04:53,900 --> 00:04:57,500 So since it is uppercase in the table, 90 00:04:57,500 --> 00:05:00,630 we put uppercase in the statement as well. 91 00:05:00,630 --> 00:05:04,160 So here we're using a condition to restrict the rows that 92 00:05:04,160 --> 00:05:06,540 come back in the query. 93 00:05:06,540 --> 00:05:10,650 And we can also do this. 94 00:05:10,650 --> 00:05:12,840 And that is the nonequivalence. 95 00:05:12,840 --> 00:05:15,310 So this is a nonequivalence query. 96 00:05:15,310 --> 00:05:17,280 So we're saying select * from the EMP 97 00:05:17,280 --> 00:05:19,830 table, all the columns from the EMP table 98 00:05:19,830 --> 00:05:22,440 where the job is not salesman. 99 00:05:22,440 --> 00:05:27,850 And execute, and so all of the people and employee information 100 00:05:27,850 --> 00:05:30,970 in the table come back except those 101 00:05:30,970 --> 00:05:32,680 that have the job salesman. 102 00:05:32,680 --> 00:05:36,400 You can see there's no salesman here in the rows. 103 00:05:36,400 --> 00:05:41,380 So select is a clause, from is a clause, and where is a clause. 104 00:05:41,380 --> 00:05:43,630 Now, where is optional, and we're 105 00:05:43,630 --> 00:05:47,050 going to look at another optional clause-- 106 00:05:47,050 --> 00:05:49,080 order by. 107 00:05:49,080 --> 00:05:53,030 So the order by clause is going to be used to sort data. 108 00:05:53,030 --> 00:05:58,070 So let's say that we want to see this data in a certain order. 109 00:05:58,070 --> 00:06:00,460 So let's decide-- what should we order this by? 110 00:06:00,460 --> 00:06:03,820 It looks like [INAUDIBLE] is already ordered. 111 00:06:03,820 --> 00:06:07,180 Let's order by their date that they were hired. 112 00:06:07,180 --> 00:06:10,390 So we say order by hire date. 113 00:06:10,390 --> 00:06:13,260 Always add the semicolon at the end. 114 00:06:13,260 --> 00:06:16,970 And click Run Statement. 115 00:06:16,970 --> 00:06:19,460 So again, we're doing select *, so we're 116 00:06:19,460 --> 00:06:22,490 getting all the columns, all of the rows, 117 00:06:22,490 --> 00:06:26,630 but we're just ordering them by the date that they were hired. 118 00:06:26,630 --> 00:06:28,910 So this is how we get intelligent information 119 00:06:28,910 --> 00:06:30,170 from a database. 120 00:06:30,170 --> 00:06:34,350 We use this massive information to answer questions. 121 00:06:34,350 --> 00:06:36,530 So let's extend this one more time. 122 00:06:36,530 --> 00:06:44,960 Let's put a where clause in here where job = 'SALESMAN," 123 00:06:44,960 --> 00:06:46,610 order by hire date. 124 00:06:46,610 --> 00:06:49,850 So here we're using the select clause, the from, the where, 125 00:06:49,850 --> 00:06:51,890 and the order by clause. 126 00:06:51,890 --> 00:06:55,900 We execute, and we have all of our information 127 00:06:55,900 --> 00:06:59,530 on our sales people, starting at the oldest hire date 128 00:06:59,530 --> 00:07:02,540 to the most recent hire date. 10259

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.