All language subtitles for [SubtitleTools.com] Monitoring Sessions - 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,380 --> 00:00:05,040 We're going to be doing a little work with monitoring sessions. 2 00:00:05,040 --> 00:00:07,980 And this is important because monitoring sessions 3 00:00:07,980 --> 00:00:11,640 is one of the core things that a DBA does, or at least 4 00:00:11,640 --> 00:00:15,660 the ability to go in and find a particular session. 5 00:00:15,660 --> 00:00:19,320 So if a session has a job that's hung or long-running 6 00:00:19,320 --> 00:00:21,150 and it needs to be killed for some reason, 7 00:00:21,150 --> 00:00:24,210 a DBA needs to go in and find the session, 8 00:00:24,210 --> 00:00:26,880 see what it's doing, or possibly disconnect it 9 00:00:26,880 --> 00:00:28,330 from the database. 10 00:00:28,330 --> 00:00:30,690 So to do this, we need some sessions 11 00:00:30,690 --> 00:00:32,730 connected to our database, so I'm 12 00:00:32,730 --> 00:00:38,540 going to open one with the Kara user, 13 00:00:38,540 --> 00:00:42,500 and then a separate one from SQL Plus, or Scott. 14 00:00:45,370 --> 00:00:47,590 All right, so there's a lot of ways 15 00:00:47,590 --> 00:00:50,480 actually that we can look at session information, 16 00:00:50,480 --> 00:00:53,140 and most of those involve leveraging the data dictionary. 17 00:00:53,140 --> 00:00:55,180 And that's what we're going to focus the most on. 18 00:00:55,180 --> 00:00:57,940 But I did want to point out that SQL Developer has a session 19 00:00:57,940 --> 00:00:58,930 monitoring tool. 20 00:00:58,930 --> 00:01:03,340 If we go up to Tools, then Monitor Sessions, 21 00:01:03,340 --> 00:01:05,650 we select from our dropdown whichever one 22 00:01:05,650 --> 00:01:07,690 of our connections we would use. 23 00:01:07,690 --> 00:01:09,640 And we're going to want a system account, 24 00:01:09,640 --> 00:01:12,700 because we're going to want to have the privileges to look 25 00:01:12,700 --> 00:01:15,970 at v$session, because that's what the tool will do, 26 00:01:15,970 --> 00:01:17,710 and click OK. 27 00:01:17,710 --> 00:01:20,800 So notice here that we've got a Kara user connected 28 00:01:20,800 --> 00:01:21,910 and a Scott. 29 00:01:21,910 --> 00:01:24,250 And then of course our system has a connection 30 00:01:24,250 --> 00:01:27,200 to run this monitor session's browser. 31 00:01:27,200 --> 00:01:30,070 And so it has information such as the machine, 32 00:01:30,070 --> 00:01:32,500 the operating system user, whether it's 33 00:01:32,500 --> 00:01:35,560 active or inactive, the module it's using, 34 00:01:35,560 --> 00:01:38,920 which will basically normally be the application name. 35 00:01:38,920 --> 00:01:41,680 So we see a couple with SQL Developer and one 36 00:01:41,680 --> 00:01:43,210 with SQL Plus. 37 00:01:43,210 --> 00:01:46,270 So that can be useful if we're working in SQL Developer 38 00:01:46,270 --> 00:01:49,580 and want to look at basic system information. 39 00:01:49,580 --> 00:01:51,580 I'm going to close out of that. 40 00:01:51,580 --> 00:01:54,100 But what we want to spend the majority of our time doing 41 00:01:54,100 --> 00:01:56,330 is leveraging the data dictionary. 42 00:01:56,330 --> 00:02:00,500 So we'll be looking at v$session and v$process. 43 00:02:00,500 --> 00:02:02,480 So I've got my system connection here. 44 00:02:02,480 --> 00:02:07,550 I'm going to right-click, go down to Open SQL Worksheet. 45 00:02:07,550 --> 00:02:11,680 So let's take a basic look first at v$session. 46 00:02:11,680 --> 00:02:13,830 We'll do select star from v$session. 47 00:02:16,790 --> 00:02:21,440 Now, SQL Developer shows us the output from this command. 48 00:02:21,440 --> 00:02:25,910 And I did want to mention that v$session is one of the widest 49 00:02:25,910 --> 00:02:27,920 data dictionary views that there is, 50 00:02:27,920 --> 00:02:31,310 and it does seem they add to it continually as versions 51 00:02:31,310 --> 00:02:33,490 increase. 52 00:02:33,490 --> 00:02:35,380 So you can see as I scan here there 53 00:02:35,380 --> 00:02:38,710 are a really large number of columns. 54 00:02:38,710 --> 00:02:41,220 But the kind of information that we have here-- 55 00:02:41,220 --> 00:02:47,210 things like SID and serial number, the username, status, 56 00:02:47,210 --> 00:02:49,460 the operating system user-- 57 00:02:49,460 --> 00:02:53,480 one thing that's different than the SQL Developer session 58 00:02:53,480 --> 00:02:57,740 browser is that we're going to include in v$session all 59 00:02:57,740 --> 00:02:59,670 of the background processes. 60 00:02:59,670 --> 00:03:03,920 So these are going to be some of the ones where username is null 61 00:03:03,920 --> 00:03:07,880 and the OS user is system instead of the SRIES user 62 00:03:07,880 --> 00:03:09,440 that's connected in. 63 00:03:09,440 --> 00:03:13,970 So what we want to do normally when we v$session is we want 64 00:03:13,970 --> 00:03:16,070 to kind of be more selective with it. 65 00:03:16,070 --> 00:03:18,890 So let's bring it down a little bit. 66 00:03:18,890 --> 00:03:31,100 Username, status, OS user, machine, action, logon_time, 67 00:03:31,100 --> 00:03:38,020 event, and state from v$session-- 68 00:03:38,020 --> 00:03:40,660 so this limits the information a little bit more. 69 00:03:40,660 --> 00:03:43,540 So when we go to v$session, normally we're looking 70 00:03:43,540 --> 00:03:46,610 for something. 71 00:03:46,610 --> 00:03:50,300 This would help us kind of bring down the volume of information 72 00:03:50,300 --> 00:03:53,680 that we have in v$session into a more manageable piece. 73 00:03:53,680 --> 00:03:55,970 But of course that's the important thing and the beauty 74 00:03:55,970 --> 00:03:58,730 really of using the data dictionary, 75 00:03:58,730 --> 00:04:02,420 is that whatever information you want, you can just select it. 76 00:04:02,420 --> 00:04:05,180 Whereas with our SQL Developer session browser, 77 00:04:05,180 --> 00:04:07,700 that information is already decided for you. 78 00:04:07,700 --> 00:04:10,820 All right, so we have things here like the usernames. 79 00:04:10,820 --> 00:04:12,430 We have a Kara user here. 80 00:04:12,430 --> 00:04:15,350 There's status, inactive or active. 81 00:04:15,350 --> 00:04:17,000 Inactive indicates that they're logged 82 00:04:17,000 --> 00:04:19,340 in but not executing anything. 83 00:04:19,340 --> 00:04:24,290 The OS user and machine, the action that's going on, 84 00:04:24,290 --> 00:04:27,240 the logon time, so the time that they logged on, 85 00:04:27,240 --> 00:04:29,670 and the event, so whatever event is 86 00:04:29,670 --> 00:04:33,180 occurring for them at this moment, and then the state. 87 00:04:33,180 --> 00:04:34,830 So it could be waiting, it could be 88 00:04:34,830 --> 00:04:37,440 waiting on a specific action, it could be running, 89 00:04:37,440 --> 00:04:39,970 it could be any of those different things. 90 00:04:39,970 --> 00:04:43,380 So what if we want to be a little more targeted about who 91 00:04:43,380 --> 00:04:44,550 we're looking at? 92 00:04:44,550 --> 00:04:48,270 Well, we simply add a where clause, where username 93 00:04:48,270 --> 00:04:51,240 equals Kara. 94 00:04:51,240 --> 00:04:55,980 Now we have Kara's specific information. 95 00:04:55,980 --> 00:04:59,450 We can also take a look at Scott. 96 00:04:59,450 --> 00:05:01,550 And we can see some differences here, 97 00:05:01,550 --> 00:05:03,890 the way it shows up, because one of them 98 00:05:03,890 --> 00:05:07,190 is a tool that connects in, essentially remotely. 99 00:05:07,190 --> 00:05:10,250 It's basically coming out and back in over the network, 100 00:05:10,250 --> 00:05:12,460 whereas our SQL Plus session is connecting locally. 101 00:05:15,370 --> 00:05:17,590 What if we needed some direct information 102 00:05:17,590 --> 00:05:19,670 about the background processes? 103 00:05:19,670 --> 00:05:22,030 So I mentioned that the background processes are listed 104 00:05:22,030 --> 00:05:23,740 in v$session. 105 00:05:23,740 --> 00:05:26,470 So what if we want to exclude the other sessions 106 00:05:26,470 --> 00:05:29,510 and just look at background process information? 107 00:05:29,510 --> 00:05:32,190 Well, we could do a query like this. 108 00:05:37,550 --> 00:05:41,230 So we'll select program, status, action, and logon_time where 109 00:05:41,230 --> 00:05:43,990 the type equals BACKGROUND. 110 00:05:43,990 --> 00:05:45,820 So notice here that we should be able to see 111 00:05:45,820 --> 00:05:47,890 some of the processes that we're familiar with, 112 00:05:47,890 --> 00:05:50,740 like the checkpoint process. 113 00:05:50,740 --> 00:05:56,570 And further down we have SMON, PMON, the database writer 114 00:05:56,570 --> 00:06:00,200 process, DBW0, and so on and so forth. 115 00:06:00,200 --> 00:06:01,620 And a lot of these other processes 116 00:06:01,620 --> 00:06:05,960 are slave processes to the parent process. 117 00:06:05,960 --> 00:06:09,470 So we can get background process information from v$session 118 00:06:09,470 --> 00:06:10,390 as well. 119 00:06:10,390 --> 00:06:12,680 To look at another way and leverage a different data 120 00:06:12,680 --> 00:06:20,420 dictionary view, so here we're going to look at a different 121 00:06:20,420 --> 00:06:22,800 view, v$process. 122 00:06:22,800 --> 00:06:25,280 So every session that connects into the database is going 123 00:06:25,280 --> 00:06:27,350 to have a process that goes with it, 124 00:06:27,350 --> 00:06:30,470 and so we can also get background process information 125 00:06:30,470 --> 00:06:32,730 from the v$process, as well. 126 00:06:32,730 --> 00:06:35,210 So here we have more directly their name, we 127 00:06:35,210 --> 00:06:39,430 have the PMON and the MMAN, log writer process, 128 00:06:39,430 --> 00:06:40,780 so on and so forth. 129 00:06:40,780 --> 00:06:42,670 And then it actually has their trace file, 130 00:06:42,670 --> 00:06:44,830 the location of the trace file that they're 131 00:06:44,830 --> 00:06:46,670 writing to at this moment. 132 00:06:46,670 --> 00:06:49,930 So if any messages come through any of those processes, 133 00:06:49,930 --> 00:06:53,620 they'll be written in those trace files. 134 00:06:53,620 --> 00:06:55,980 So one of the things that we'll need to do as a DBA 135 00:06:55,980 --> 00:07:00,280 from time to time is kill a process or kill a session. 136 00:07:00,280 --> 00:07:02,070 So how do we find the information 137 00:07:02,070 --> 00:07:04,520 needed to kill a session? 138 00:07:04,520 --> 00:07:05,870 Well, let's try this query. 139 00:07:11,470 --> 00:07:15,310 So this is going to give us the username and the SID 140 00:07:15,310 --> 00:07:17,920 and serial number for the session. 141 00:07:17,920 --> 00:07:20,140 So these two pieces of information 142 00:07:20,140 --> 00:07:23,290 are what we need when we want to kill a session. 143 00:07:23,290 --> 00:07:25,990 We can't simply say, kill the Kara session, 144 00:07:25,990 --> 00:07:28,150 because there could be many Kara sessions. 145 00:07:28,150 --> 00:07:32,170 So we're going to identify that with a SID and a serial number. 146 00:07:32,170 --> 00:07:36,010 The SID is not always unique, but the two together, 147 00:07:36,010 --> 00:07:38,200 SID and serial number, are. 148 00:07:38,200 --> 00:07:40,000 And keep in mind that SID here should not 149 00:07:40,000 --> 00:07:43,890 be confused with the database SID or system identifier. 150 00:07:43,890 --> 00:07:49,220 SID in this case really refers to a session identifier. 151 00:07:49,220 --> 00:07:53,360 So I have my Scott session here. 152 00:07:53,360 --> 00:07:56,040 So let's kill that session. 153 00:07:56,040 --> 00:07:59,620 Altar system, kill session. 154 00:07:59,620 --> 00:08:06,310 And in single quotes we put the SID and the serial number. 155 00:08:06,310 --> 00:08:08,010 We'll double check that to make sure. 156 00:08:08,010 --> 00:08:12,440 All right, so we're killing the Scott session, 130 and 167. 157 00:08:12,440 --> 00:08:15,200 We execute. 158 00:08:15,200 --> 00:08:17,200 Now, when we come back over here, 159 00:08:17,200 --> 00:08:22,630 and Scott attempts to select star from emp, 160 00:08:22,630 --> 00:08:25,540 he gets a message that his session has been killed. 161 00:08:25,540 --> 00:08:29,190 So that's a little bit about session management. 13230

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