All language subtitles for [SubtitleTools.com] Synonyms - 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,410 --> 00:00:04,390 In this lesson, we'll be looking at synonyms. 2 00:00:04,390 --> 00:00:06,780 Now a synonym in the Oracle database 3 00:00:06,780 --> 00:00:08,940 is an object that allows for basically 4 00:00:08,940 --> 00:00:13,740 an alias to another database object name, usually a table. 5 00:00:13,740 --> 00:00:17,610 And that's to avoid schema notations or table-dot 6 00:00:17,610 --> 00:00:20,530 notations that we sometimes refer to. 7 00:00:20,530 --> 00:00:24,900 So we'll look at this example in a moment, but to describe this, 8 00:00:24,900 --> 00:00:29,430 if the user Kara logs in to the database and wants to do 9 00:00:29,430 --> 00:00:34,230 a select from the table called emp in Scott's schema, 10 00:00:34,230 --> 00:00:39,180 she can't simply do select* from emp because emp is not in her 11 00:00:39,180 --> 00:00:41,280 schema, it's in Scott's schema. 12 00:00:41,280 --> 00:00:46,500 So she has to do a select* from scott.emp. 13 00:00:46,500 --> 00:00:48,510 And obviously, in an organization 14 00:00:48,510 --> 00:00:52,500 with lots and lots of tables with many different schemas, 15 00:00:52,500 --> 00:00:55,980 it's considered by some to be problematic to have 16 00:00:55,980 --> 00:01:00,600 to notate a table that way every time, to always have 17 00:01:00,600 --> 00:01:05,760 to use the table notation where we put the schema dot and then 18 00:01:05,760 --> 00:01:06,900 the table name. 19 00:01:06,900 --> 00:01:11,250 So that's considered by some to be extra code, more work, 20 00:01:11,250 --> 00:01:12,250 and those kind of thing. 21 00:01:12,250 --> 00:01:16,980 So a synonym allows for us to create an alias for the table 22 00:01:16,980 --> 00:01:21,960 so we don't have to use the schema-dot-table notation. 23 00:01:21,960 --> 00:01:23,710 There are two different kinds of synonyms. 24 00:01:23,710 --> 00:01:26,460 There's a private synonym, and a private synonym 25 00:01:26,460 --> 00:01:28,210 is owned by the user. 26 00:01:28,210 --> 00:01:31,260 So in our case, Kara user would own 27 00:01:31,260 --> 00:01:33,720 a private synonym that was an alias that 28 00:01:33,720 --> 00:01:35,850 pointed to another table. 29 00:01:35,850 --> 00:01:38,130 But we also have public synonyms. 30 00:01:38,130 --> 00:01:41,500 And public synonyms are available to every user. 31 00:01:41,500 --> 00:01:44,160 So you could think of them as a global alias 32 00:01:44,160 --> 00:01:45,270 for a particular table. 33 00:01:45,270 --> 00:01:46,770 And sometimes public synonyms are 34 00:01:46,770 --> 00:01:51,120 used on a table that's very common to all applications, 35 00:01:51,120 --> 00:01:55,320 so some sort of lookup table or a table with company 36 00:01:55,320 --> 00:01:59,370 information that belong to all the different applications that 37 00:01:59,370 --> 00:02:01,840 are supported by the database. 38 00:02:01,840 --> 00:02:04,830 So private synonyms and public synonyms. 39 00:02:04,830 --> 00:02:07,830 A couple of words of warning about synonyms. 40 00:02:07,830 --> 00:02:09,810 Too many synonyms in a database can 41 00:02:09,810 --> 00:02:13,020 be really confusing as far as what is pointing 42 00:02:13,020 --> 00:02:15,610 to what in terms of aliases. 43 00:02:15,610 --> 00:02:18,660 So that's something that has to be taken into consideration. 44 00:02:18,660 --> 00:02:22,370 If you use a synonym-based strategy in your database, 45 00:02:22,370 --> 00:02:25,440 it has to be fairly thought out and defined 46 00:02:25,440 --> 00:02:27,390 before you jump into that. 47 00:02:27,390 --> 00:02:29,100 The other thing that should be considered 48 00:02:29,100 --> 00:02:31,230 is that coding standards may actually 49 00:02:31,230 --> 00:02:34,710 require schema notation, and for very good reasons 50 00:02:34,710 --> 00:02:39,060 because, when you look at a piece of code that's selecting 51 00:02:39,060 --> 00:02:41,400 from tables in the database, it's 52 00:02:41,400 --> 00:02:45,630 very helpful to see that the schema-dot-table notation is 53 00:02:45,630 --> 00:02:50,280 there, so you know exactly what owner owns the object that's 54 00:02:50,280 --> 00:02:52,200 being referenced in the code. 55 00:02:52,200 --> 00:02:53,640 So some coding standards actually 56 00:02:53,640 --> 00:02:56,550 require you to use schema notation 57 00:02:56,550 --> 00:02:58,980 and certainly wouldn't get any argument from me. 58 00:02:58,980 --> 00:03:02,250 But synonyms can be used as aliases in situations 59 00:03:02,250 --> 00:03:04,750 where that is advantageous. 60 00:03:04,750 --> 00:03:09,380 So let's connect up to our Kara user. 61 00:03:09,380 --> 00:03:11,280 And just to prove this out a little bit, 62 00:03:11,280 --> 00:03:15,510 let's try select star from emp. 63 00:03:15,510 --> 00:03:17,310 Of course, we get table or view does not 64 00:03:17,310 --> 00:03:22,410 exist because Kara owns no tables named emp. 65 00:03:22,410 --> 00:03:24,510 What we're wanting to reference is the emp table 66 00:03:24,510 --> 00:03:26,130 that's in the Scott schema. 67 00:03:26,130 --> 00:03:30,950 So we say select* from scott.emp. 68 00:03:30,950 --> 00:03:33,970 And then we see the data. 69 00:03:33,970 --> 00:03:39,090 So let's attempt to create a synonym in Kara's schema 70 00:03:39,090 --> 00:03:42,020 that points to the scott.emp table. 71 00:03:42,020 --> 00:03:50,990 So we say, create synonym emp for scott.emp. 72 00:03:50,990 --> 00:03:53,450 Now we get an error, an insufficient privileges 73 00:03:53,450 --> 00:03:54,380 error in this case. 74 00:03:54,380 --> 00:03:56,180 And I wanted to show this to you just 75 00:03:56,180 --> 00:03:59,480 to make the point that creating a synonym 76 00:03:59,480 --> 00:04:00,980 is creating a database object. 77 00:04:00,980 --> 00:04:04,220 And as such, it has certain permissions that go with it, 78 00:04:04,220 --> 00:04:07,130 so system privileges that are required. 79 00:04:07,130 --> 00:04:14,310 So I'm going to pull up command prompt, and we'll SQL plus. 80 00:04:14,310 --> 00:04:21,040 And we will grant create synonym to Kara. 81 00:04:21,040 --> 00:04:28,890 I'm going to clear this and have Kara create that synonym. 82 00:04:28,890 --> 00:04:30,480 So that is a private synonym. 83 00:04:30,480 --> 00:04:34,880 That synonym exists in Kara's schema. 84 00:04:34,880 --> 00:04:37,530 What about a public synonym? 85 00:04:37,530 --> 00:04:40,410 So let's have Kara create a public synonym 86 00:04:40,410 --> 00:04:43,580 for the DEPT table in the Scott schema. 87 00:04:43,580 --> 00:04:47,220 And that will make it available in terms of that alias 88 00:04:47,220 --> 00:04:48,060 to all users. 89 00:04:54,840 --> 00:04:58,460 And again, we get an insufficient privileges there. 90 00:04:58,460 --> 00:05:01,940 So creating a private synonym is a different privilege 91 00:05:01,940 --> 00:05:04,640 than creating a public synonym. 92 00:05:04,640 --> 00:05:09,190 So we need to grant create public synonym to Kara as well. 93 00:05:14,220 --> 00:05:16,230 So now Kara has a private synonym 94 00:05:16,230 --> 00:05:20,580 that refers to the scott.emp table and a public synonym that 95 00:05:20,580 --> 00:05:27,200 refers to scott.dept. So whereas before we couldn't do this, 96 00:05:27,200 --> 00:05:31,160 now we can because the private synonym emp refers back 97 00:05:31,160 --> 00:05:35,240 to the scott.emp table because a private synonym exists for it, 98 00:05:35,240 --> 00:05:38,720 and then the same would be for the dept table as well. 8089

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