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:05,600
In this lesson, we'll be looking
at index-organized tables.
2
00:00:05,600 --> 00:00:08,930
So typical tables--
typical relational tables--
3
00:00:08,930 --> 00:00:11,710
created with the
CREATE TABLE command
4
00:00:11,710 --> 00:00:14,510
are what we refer to
as heap organized.
5
00:00:14,510 --> 00:00:18,320
So that means if I
insert a row into a table
6
00:00:18,320 --> 00:00:21,290
and then I insert a second row
into the table, and a third,
7
00:00:21,290 --> 00:00:24,140
those rows are actually
stored in the order
8
00:00:24,140 --> 00:00:25,550
that we put them in the table.
9
00:00:25,550 --> 00:00:29,750
That's actually how they're
stored in the database blocks.
10
00:00:29,750 --> 00:00:33,020
An index-organized
table, or IOT,
11
00:00:33,020 --> 00:00:35,330
is actually structured
in an index.
12
00:00:35,330 --> 00:00:39,170
So the table is not
structured heap organized.
13
00:00:39,170 --> 00:00:41,290
It is actually
structured in an index.
14
00:00:41,290 --> 00:00:47,630
So essentially, the table and
the index are built together.
15
00:00:47,630 --> 00:00:51,650
So what's unique about an
IOT is that it's dynamic.
16
00:00:51,650 --> 00:00:54,320
Because it's
structured in an index,
17
00:00:54,320 --> 00:00:58,430
the rows can be moved to
preserve that structure.
18
00:00:58,430 --> 00:01:02,780
So index-organized tables can
be good in certain situations,
19
00:01:02,780 --> 00:01:05,000
but because of the way
that they're built,
20
00:01:05,000 --> 00:01:08,450
they're used in
specific situations.
21
00:01:08,450 --> 00:01:11,870
So they're good
for small tables,
22
00:01:11,870 --> 00:01:15,710
and particularly for tables
that function as lookup tables--
23
00:01:15,710 --> 00:01:19,730
so maybe at a table that has
a relatively small number
24
00:01:19,730 --> 00:01:22,130
of rows, something like--
25
00:01:22,130 --> 00:01:23,910
maybe as an example--
26
00:01:23,910 --> 00:01:28,100
a table that has cities and
zip codes and counties, maybe,
27
00:01:28,100 --> 00:01:29,300
for lookups.
28
00:01:29,300 --> 00:01:32,570
You already have the table,
and if you can load it
29
00:01:32,570 --> 00:01:35,330
in an ordered way that
it's loaded in the same way
30
00:01:35,330 --> 00:01:39,500
that it's structured, it can be
fairly quick to load that data,
31
00:01:39,500 --> 00:01:42,720
and then that can be used
as an index-organized table.
32
00:01:42,720 --> 00:01:45,440
It's also good, with those
small tables, where there's
33
00:01:45,440 --> 00:01:48,690
an exact match on the value.
34
00:01:48,690 --> 00:01:51,200
So we're not using
a lot of functions.
35
00:01:51,200 --> 00:01:54,470
We really are using an
index-organized table, maybe,
36
00:01:54,470 --> 00:01:58,700
to join to another table,
or as a quick lookup table.
37
00:01:58,700 --> 00:02:02,450
And it can also have the
benefit of reducing storage
38
00:02:02,450 --> 00:02:06,620
requirements, because you're not
storing a table and an index.
39
00:02:06,620 --> 00:02:08,390
You're actually
storing them together.
40
00:02:08,390 --> 00:02:13,970
So there is some degree of
savings in terms of storage.
41
00:02:13,970 --> 00:02:16,130
But you wouldn't want a
really, really large table
42
00:02:16,130 --> 00:02:20,060
in an index-organized table, and
you wouldn't want a table to be
43
00:02:20,060 --> 00:02:23,930
defined as an IOT if you're
going to be changing the values
44
00:02:23,930 --> 00:02:26,420
a lot, because that operation--
45
00:02:26,420 --> 00:02:28,340
while it is dynamic--
46
00:02:28,340 --> 00:02:31,970
the rules of an IOT
are that it must store
47
00:02:31,970 --> 00:02:33,260
the table in that structure.
48
00:02:33,260 --> 00:02:35,390
It must be structured
in an index.
49
00:02:35,390 --> 00:02:38,630
It will have to move those
rows if you change them,
50
00:02:38,630 --> 00:02:41,550
and so that can be a
pretty expensive operation.
51
00:02:41,550 --> 00:02:44,360
But if that's not a
problem, then an IOT
52
00:02:44,360 --> 00:02:46,460
can be really useful,
because it's not
53
00:02:46,460 --> 00:02:49,940
a matter of scanning an
index, finding the row ID,
54
00:02:49,940 --> 00:02:51,470
and then returning the row.
55
00:02:51,470 --> 00:02:54,470
It's finding the value
and returning the row.
56
00:02:54,470 --> 00:02:56,780
So let's look at
creating an IOT.
57
00:03:00,800 --> 00:03:05,490
And we'll create table
state_lookup_iot.
58
00:03:08,310 --> 00:03:20,610
You have an area code column,
state name, city name.
59
00:03:20,610 --> 00:03:22,710
One of the key
things about an IOT
60
00:03:22,710 --> 00:03:26,280
is that we have to define
a primary key for it.
61
00:03:26,280 --> 00:03:29,820
And that's going to be what
defines its organization
62
00:03:29,820 --> 00:03:34,260
We say primary key area code.
63
00:03:34,260 --> 00:03:37,080
So the upper structure,
here, is fairly simple,
64
00:03:37,080 --> 00:03:40,230
and this is just
defining a primary key.
65
00:03:40,230 --> 00:03:45,060
What makes an IOT unique is the
next part of the statement--
66
00:03:45,060 --> 00:03:49,830
organization index, and then
we can put it in a table space
67
00:03:49,830 --> 00:03:52,170
if we'd like.
68
00:03:52,170 --> 00:03:56,640
So now, then, we can load
the state_lookup_iot table,
69
00:03:56,640 --> 00:03:58,520
and when we load
the data, it will
70
00:03:58,520 --> 00:04:03,060
be structured in the form
of an index on area code.
5863
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.