Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,330 --> 00:00:02,790
In this lesson,
we're going to look
2
00:00:02,790 --> 00:00:08,290
at tablespaces, specifically
smallfile tablespaces.
3
00:00:08,290 --> 00:00:10,440
So a tablespace is
the logical name
4
00:00:10,440 --> 00:00:14,520
given to one or more
physical data files.
5
00:00:14,520 --> 00:00:18,450
So the benefit of having
something like a tablespace
6
00:00:18,450 --> 00:00:24,150
is so that when a user wants
to create a table that belongs
7
00:00:24,150 --> 00:00:27,060
in a certain place
or a data file,
8
00:00:27,060 --> 00:00:30,720
they don't need to specify
the entire data file name.
9
00:00:30,720 --> 00:00:33,870
So the physical aspect
of it is the data file.
10
00:00:33,870 --> 00:00:36,840
And the tablespace
is the logical name.
11
00:00:36,840 --> 00:00:40,320
Now, smallfile tablespaces
are the default type.
12
00:00:40,320 --> 00:00:41,520
They're not the only type.
13
00:00:41,520 --> 00:00:43,950
There's also
bigfile tablespaces.
14
00:00:43,950 --> 00:00:45,670
But for the purposes
of this lesson,
15
00:00:45,670 --> 00:00:48,310
we're looking at
smallfile tablespaces.
16
00:00:48,310 --> 00:00:52,300
So when you create a tablespace
using the default method,
17
00:00:52,300 --> 00:00:54,460
if you will,
smallfile tablespace
18
00:00:54,460 --> 00:00:56,950
is what you'll have created.
19
00:00:56,950 --> 00:01:01,200
And the maximum number of data
files per smallfile tablespace
20
00:01:01,200 --> 00:01:03,090
is 1,022.
21
00:01:03,090 --> 00:01:09,430
So you can create a tablespace
with 1,022 data files in it.
22
00:01:09,430 --> 00:01:12,900
So again, it's that idea of
a logical grouping or logical
23
00:01:12,900 --> 00:01:16,640
name on top of physical files.
24
00:01:16,640 --> 00:01:20,740
The data dictionary views that
we use for tablespaces are
25
00:01:20,740 --> 00:01:25,310
DBA_TABLESPACES
and V$TABLESPACE.
26
00:01:25,310 --> 00:01:29,630
So let's take a look at what we
have in the way of tablespaces.
27
00:01:29,630 --> 00:01:33,230
Now, in order to look at
data dictionary information
28
00:01:33,230 --> 00:01:36,860
of this type, since it
is more administrative,
29
00:01:36,860 --> 00:01:39,140
we can't use our Scott
account, because Scott
30
00:01:39,140 --> 00:01:42,080
is an account that owns some
objects and can do work.
31
00:01:42,080 --> 00:01:45,290
But it can't do
administrative activities.
32
00:01:45,290 --> 00:01:48,320
So we're going to click the
plus by our system Oracle
33
00:01:48,320 --> 00:01:49,830
connection.
34
00:01:49,830 --> 00:01:53,720
And we're going to select
star from DBA_TABLESPACES.
35
00:02:00,240 --> 00:02:04,150
So this gives us a list of the
tablespaces that we have here.
36
00:02:04,150 --> 00:02:07,830
So we have SYSTEM, which holds
the data dictionary; SYSAUX,
37
00:02:07,830 --> 00:02:10,230
which holds the
workload repository;
38
00:02:10,230 --> 00:02:12,300
UNDO for undo tablespace--
39
00:02:12,300 --> 00:02:15,420
that holds undo data;
TEMP for temporary data,
40
00:02:15,420 --> 00:02:18,000
and then a USERS
tablespace that's actually
41
00:02:18,000 --> 00:02:20,400
a tablespace with a
non-specific data file in it
42
00:02:20,400 --> 00:02:23,260
that's just for user data.
43
00:02:23,260 --> 00:02:25,590
We can see similar types
of information when we look
44
00:02:25,590 --> 00:02:28,680
at V$_TABLESPACE.
45
00:02:32,040 --> 00:02:34,320
A little bit less
information here.
46
00:02:34,320 --> 00:02:39,090
That's why a lot of times you'll
see DBAs use DBA_TABLESPACES
47
00:02:39,090 --> 00:02:41,560
to get more information.
48
00:02:41,560 --> 00:02:45,210
So let's do some activities
with tablespaces.
49
00:02:45,210 --> 00:02:48,750
So the first activity we want
to do is create a tablespace.
50
00:02:48,750 --> 00:02:50,340
Now, when we create
a tablespace,
51
00:02:50,340 --> 00:02:53,160
we specify the name
of the tablespace,
52
00:02:53,160 --> 00:02:56,370
the data file that we
want to use, and the size.
53
00:02:56,370 --> 00:02:58,290
So the first thing
we need to know
54
00:02:58,290 --> 00:03:01,380
is where are the data files
located, because we don't want
55
00:03:01,380 --> 00:03:05,730
to create a database data
file for this tablespace
56
00:03:05,730 --> 00:03:08,130
in a non-standard
place, in the wrong C
57
00:03:08,130 --> 00:03:11,560
drive or the wrong directory
or anything of that nature.
58
00:03:11,560 --> 00:03:17,550
So we're going to refer
back to DBA_DATA_FILES.
59
00:03:17,550 --> 00:03:23,190
We see that data file locations
are of this path in my example,
60
00:03:23,190 --> 00:03:30,370
so we will create
tablespace example datafile.
61
00:03:30,370 --> 00:03:33,250
And it'll be this entire
path, which I'm actually
62
00:03:33,250 --> 00:03:37,820
just going to copy.
63
00:03:37,820 --> 00:03:43,510
Take away the file name that I
copied, and put example01.dbf.
64
00:03:46,820 --> 00:03:50,290
size 100 meg.
65
00:03:50,290 --> 00:03:54,210
So a tablespace name, a
data file name and location,
66
00:03:54,210 --> 00:03:57,700
full path, and the size.
67
00:03:57,700 --> 00:04:00,620
And now I create.
68
00:04:00,620 --> 00:04:03,110
A tablespace is created.
69
00:04:03,110 --> 00:04:06,610
And if we select
from DBA_TABLESPACES,
70
00:04:06,610 --> 00:04:09,100
we now see our tablespace.
71
00:04:09,100 --> 00:04:12,040
If we select from
DBA_DATA_FILES,
72
00:04:12,040 --> 00:04:15,550
we see it in
DBA_DATA_FILES as well.
73
00:04:15,550 --> 00:04:17,950
Now, there's two
ways to increase
74
00:04:17,950 --> 00:04:21,460
the size of a tablespace.
75
00:04:21,460 --> 00:04:24,850
We can either increase the
size of the data files,
76
00:04:24,850 --> 00:04:27,860
or we can add data files to it.
77
00:04:27,860 --> 00:04:32,860
So in this example, let's add
a data file to our tablespace.
78
00:04:37,450 --> 00:04:39,580
This time I'm going to
call it example02.dbf.
79
00:04:42,260 --> 00:04:43,640
size, 50 meg.
80
00:04:48,350 --> 00:04:50,470
And now when we select
from DBA_DATA_FILES,
81
00:04:50,470 --> 00:04:53,680
we see that we have two
data files, both belonging
82
00:04:53,680 --> 00:04:56,530
to the example tablespace.
83
00:04:56,530 --> 00:04:59,530
So we said that the other
way that we could increase
84
00:04:59,530 --> 00:05:03,610
the size of a tablespace
is to increase
85
00:05:03,610 --> 00:05:07,030
the size of the data files
that the tablespace contains.
86
00:05:07,030 --> 00:05:10,150
So here, we see
that this data file
87
00:05:10,150 --> 00:05:15,020
is this many bytes, which is 50
meg, as we indicated up here.
88
00:05:15,020 --> 00:05:18,820
And so we can change that
data file to a different size.
89
00:05:18,820 --> 00:05:21,190
We can either increase
it or decrease it
90
00:05:21,190 --> 00:05:22,120
with certain limits.
91
00:05:22,120 --> 00:05:25,900
We cannot decrease it more
than the data that's within it
92
00:05:25,900 --> 00:05:28,480
or the data that has
ever been within it.
93
00:05:28,480 --> 00:05:30,400
The data within
a data file forms
94
00:05:30,400 --> 00:05:31,900
what's called a high watermark.
95
00:05:31,900 --> 00:05:34,750
And we can never decrease
the size below that.
96
00:05:34,750 --> 00:05:36,550
However, we can increase it.
97
00:05:36,550 --> 00:05:38,080
And so that one of
the easiest ways
98
00:05:38,080 --> 00:05:42,020
to do this, since we're going
to use a data file command,
99
00:05:42,020 --> 00:05:45,040
if you will, is to
use the file ID.
100
00:05:45,040 --> 00:05:47,440
Rather than typing
out the entire path,
101
00:05:47,440 --> 00:05:51,170
we just refer to this
data file by its file ID.
102
00:05:51,170 --> 00:05:52,660
So I'll show you what I mean.
103
00:05:52,660 --> 00:06:00,130
alter database datafile 6,
which refers to this data file,
104
00:06:00,130 --> 00:06:02,290
resize 100 meg.
105
00:06:05,640 --> 00:06:10,290
And now in DBA_DATA_FILES, we
see that our data files are now
106
00:06:10,290 --> 00:06:13,290
both 100 meg.
107
00:06:13,290 --> 00:06:16,480
Whenever we wish to
drop a tablespace,
108
00:06:16,480 --> 00:06:21,090
we use the drop tablespace
command with the name.
109
00:06:21,090 --> 00:06:26,430
And we use the phrase "including
contents and data files."
110
00:06:30,960 --> 00:06:34,180
And now when we look
at DBA_TABLESPACES,
111
00:06:34,180 --> 00:06:37,260
our example is no longer there.
9001
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.