Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,310 --> 00:00:02,770
In this lesson,
we're going to take
2
00:00:02,770 --> 00:00:07,020
a look at our next large unit
of space, which are segments.
3
00:00:07,020 --> 00:00:09,730
And there are many
different kinds of segments,
4
00:00:09,730 --> 00:00:11,320
as we will see.
5
00:00:11,320 --> 00:00:15,320
But segments have in common that
they are composed of extents.
6
00:00:15,320 --> 00:00:20,240
So normally, we are most
concerned with table segments.
7
00:00:20,240 --> 00:00:23,020
And so segments are
composed of extents.
8
00:00:23,020 --> 00:00:26,080
And extents are
composed of blocks.
9
00:00:26,080 --> 00:00:29,020
So to look at the
structure of a segment,
10
00:00:29,020 --> 00:00:30,640
we have many extents here.
11
00:00:30,640 --> 00:00:32,710
Let's say we have
five extents, one
12
00:00:32,710 --> 00:00:36,310
of these being the first or
initial extent, and each one
13
00:00:36,310 --> 00:00:39,700
subsequently being
the next extent.
14
00:00:39,700 --> 00:00:43,600
We refer to this set of
extents as a segment.
15
00:00:43,600 --> 00:00:45,610
And a segment is
going to be sort
16
00:00:45,610 --> 00:00:49,690
of the physical analog
of something logical,
17
00:00:49,690 --> 00:00:51,140
like a table.
18
00:00:51,140 --> 00:00:55,180
So a table itself isn't
a physical object.
19
00:00:55,180 --> 00:00:58,610
It's a name that we give and
that we use to deal with it.
20
00:00:58,610 --> 00:01:01,660
But the underlying
structure that's there
21
00:01:01,660 --> 00:01:04,120
is called a segment.
22
00:01:04,120 --> 00:01:07,060
We have many different
kinds of segments,
23
00:01:07,060 --> 00:01:10,120
our most common being
table segments, which
24
00:01:10,120 --> 00:01:12,490
are going to store row data.
25
00:01:12,490 --> 00:01:15,370
So tables that
store rows of data--
26
00:01:15,370 --> 00:01:19,090
those rows are stored in
blocks, which form extents,
27
00:01:19,090 --> 00:01:21,250
which compose segments.
28
00:01:21,250 --> 00:01:23,740
We also have index segments.
29
00:01:23,740 --> 00:01:26,500
An index is a storage
structure that
30
00:01:26,500 --> 00:01:29,350
takes a portion or
a column of a table.
31
00:01:29,350 --> 00:01:31,060
It takes those values.
32
00:01:31,060 --> 00:01:33,220
And it puts them
in a structure so
33
00:01:33,220 --> 00:01:37,090
that the values can be more
easily discovered and queried
34
00:01:37,090 --> 00:01:37,870
from.
35
00:01:37,870 --> 00:01:42,460
So indexes can greatly speed
the performance of some queries.
36
00:01:42,460 --> 00:01:44,650
But that is a
physical structure.
37
00:01:44,650 --> 00:01:48,400
It requires blocks being
put together in a structure.
38
00:01:48,400 --> 00:01:51,060
And so it is stored
in a segment.
39
00:01:51,060 --> 00:01:52,800
We have undo segments.
40
00:01:52,800 --> 00:01:55,350
So anytime we do
a transaction, we
41
00:01:55,350 --> 00:01:58,260
need to store the before
image of the data.
42
00:01:58,260 --> 00:02:01,380
And so those blocks
are put into extents
43
00:02:01,380 --> 00:02:04,260
that form an undo segment.
44
00:02:04,260 --> 00:02:06,300
We have temporary segments.
45
00:02:06,300 --> 00:02:09,930
Anytime we do something
like a sorting operation--
46
00:02:09,930 --> 00:02:13,890
so we select from a table
and then order by a certain
47
00:02:13,890 --> 00:02:14,730
column--
48
00:02:14,730 --> 00:02:16,170
that's called a sort.
49
00:02:16,170 --> 00:02:18,870
And sorting occurs in memory.
50
00:02:18,870 --> 00:02:23,790
When a sort is too big
to occur 100% in memory,
51
00:02:23,790 --> 00:02:26,730
the sorting information
is written out
52
00:02:26,730 --> 00:02:29,940
to temporary segments,
out to a place in disk
53
00:02:29,940 --> 00:02:31,740
called a temporary tablespace.
54
00:02:31,740 --> 00:02:34,620
And there are temporary
segments within
55
00:02:34,620 --> 00:02:36,480
that temporary tablespace.
56
00:02:36,480 --> 00:02:39,450
And then once the sorting
operation is complete,
57
00:02:39,450 --> 00:02:42,390
part of it being in memory,
part of it being on disk,
58
00:02:42,390 --> 00:02:44,700
it's all read back
together again,
59
00:02:44,700 --> 00:02:48,530
reconstructed, and then
presented to the user.
60
00:02:48,530 --> 00:02:50,560
We also have partition segments.
61
00:02:50,560 --> 00:02:55,660
So if we use table partitioning,
which allows us to take a table
62
00:02:55,660 --> 00:03:00,130
and split it into partitions
according to a certain value--
63
00:03:00,130 --> 00:03:02,920
so we may have a 10
million row table
64
00:03:02,920 --> 00:03:08,500
that contains one million
rows of yearly data that
65
00:03:08,500 --> 00:03:10,180
goes back 10 years--
66
00:03:10,180 --> 00:03:14,980
we may choose to partition it by
year so that each partition is
67
00:03:14,980 --> 00:03:16,630
a year by itself.
68
00:03:16,630 --> 00:03:19,810
And so whenever we're
querying based on the year,
69
00:03:19,810 --> 00:03:22,610
we are able to exclude
the other partitions,
70
00:03:22,610 --> 00:03:24,700
if you will, and
only look at the data
71
00:03:24,700 --> 00:03:27,980
that we wish to see for
that particular year.
72
00:03:27,980 --> 00:03:31,030
So those are stored in
segments much in the same way
73
00:03:31,030 --> 00:03:32,810
that a table would be.
74
00:03:32,810 --> 00:03:34,480
And in the same
way that an index
75
00:03:34,480 --> 00:03:38,180
would be stored in a segment,
index partitions are stored.
76
00:03:38,180 --> 00:03:40,600
So they're a slightly
different kind of index.
77
00:03:40,600 --> 00:03:43,390
That index is based
on a partition
78
00:03:43,390 --> 00:03:46,360
or the structure of a
partition rather than just
79
00:03:46,360 --> 00:03:48,160
a table itself.
80
00:03:48,160 --> 00:03:51,970
And then we have LOB
and LOB index segments.
81
00:03:51,970 --> 00:03:54,770
So LOB stands for Large Object.
82
00:03:54,770 --> 00:03:57,550
So that might be
something like the BLOB,
83
00:03:57,550 --> 00:04:00,670
or Binary Large
Object, data type.
84
00:04:00,670 --> 00:04:03,520
And those are used
to store binary data.
85
00:04:03,520 --> 00:04:10,150
So we can actually store a video
or an MP3 or a PDF document.
86
00:04:10,150 --> 00:04:13,390
We can store all of those
things in an Oracle database.
87
00:04:13,390 --> 00:04:17,200
It requires a certain data
type and-- called a BLOB.
88
00:04:17,200 --> 00:04:21,940
And that data isn't really
contiguous with the kind
89
00:04:21,940 --> 00:04:25,000
of data that we have in
a typical table, where
90
00:04:25,000 --> 00:04:28,430
we have numbers and strings
of data and so forth.
91
00:04:28,430 --> 00:04:31,390
So those types of
objects are actually
92
00:04:31,390 --> 00:04:33,580
stored in their own segments.
93
00:04:33,580 --> 00:04:35,200
And when we query
a table, there's
94
00:04:35,200 --> 00:04:37,270
really just a
pointer in the table
95
00:04:37,270 --> 00:04:39,460
that points to the LOB segment.
96
00:04:39,460 --> 00:04:43,240
And LOBs can be indexed just in
the same way that any data can.
97
00:04:43,240 --> 00:04:46,780
And so those are used in
their own segments as well.
98
00:04:46,780 --> 00:04:49,390
So there's a high
degree of specialization
99
00:04:49,390 --> 00:04:50,620
with the segment.
100
00:04:50,620 --> 00:04:53,350
And this has really
developed over time in Oracle
101
00:04:53,350 --> 00:04:55,870
as Oracle has
refined the database.
102
00:04:55,870 --> 00:04:58,660
There used to be, really,
two or three different kinds
103
00:04:58,660 --> 00:04:59,500
of segments.
104
00:04:59,500 --> 00:05:01,510
But Oracle has
continued to refine
105
00:05:01,510 --> 00:05:04,810
the way that segments are stored
and the types of data that
106
00:05:04,810 --> 00:05:07,330
are in them and how
they're structured to be
107
00:05:07,330 --> 00:05:10,210
more consistent with
high performance.
108
00:05:10,210 --> 00:05:13,600
So we mentioned that a
segment is a physical analog,
109
00:05:13,600 --> 00:05:15,830
in some cases, of
a database object,
110
00:05:15,830 --> 00:05:21,280
such as a table, whereas we call
a table something like the EMP
111
00:05:21,280 --> 00:05:22,400
table.
112
00:05:22,400 --> 00:05:26,300
There's actually a
segment of the same name.
113
00:05:26,300 --> 00:05:28,180
So let's take a look at that.
114
00:05:31,110 --> 00:05:37,470
If we were to do a query, like
select star from user_tables
115
00:05:37,470 --> 00:05:45,070
where table_name equals EMP,
and user_tables is the data
116
00:05:45,070 --> 00:05:48,550
dictionary view that gives
us the list of tables
117
00:05:48,550 --> 00:05:52,330
that our user owns, it's very
much like what we see here
118
00:05:52,330 --> 00:05:55,360
when we expand out the
tables frame over here
119
00:05:55,360 --> 00:05:57,590
in the connections.
120
00:05:57,590 --> 00:05:59,630
So this tells us that
we have a table called
121
00:05:59,630 --> 00:06:03,510
EMP and its tablespace name
and lots of other information.
122
00:06:03,510 --> 00:06:06,290
But a table is only
a logical name.
123
00:06:06,290 --> 00:06:08,540
It's not a physical construct.
124
00:06:08,540 --> 00:06:14,290
So to see that there is also
a physical construct here,
125
00:06:14,290 --> 00:06:23,780
we could query user_segments
where segment_name equals EMP.
126
00:06:23,780 --> 00:06:27,080
And indeed, we see that we
have a segment called EMP.
127
00:06:27,080 --> 00:06:28,890
It's the segment type table.
128
00:06:28,890 --> 00:06:30,350
So we discussed
the different types
129
00:06:30,350 --> 00:06:31,940
of segments that were available.
130
00:06:31,940 --> 00:06:34,940
This is a table segment,
tablespace information
131
00:06:34,940 --> 00:06:38,390
about it, the number of
bytes, the number of blocks
132
00:06:38,390 --> 00:06:39,770
that are in the segment.
133
00:06:39,770 --> 00:06:42,550
So again, segments are
composed of extents.
134
00:06:42,550 --> 00:06:45,950
And extents are composed of
blocks and other information
135
00:06:45,950 --> 00:06:46,790
as well.
136
00:06:46,790 --> 00:06:48,860
So that kind of shows
this, that there
137
00:06:48,860 --> 00:06:53,060
is a relationship or an
analog between a table
138
00:06:53,060 --> 00:06:55,140
and its physical segment.
11005
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.