Drop or Remove Database

Microsoft SQL Server 2017 for Everyone Manipulating Tables and Data
4 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€66.56
List Price:  €95.09
You save:  €28.53
£55.25
List Price:  £78.94
You save:  £23.68
CA$98.25
List Price:  CA$140.36
You save:  CA$42.11
A$107.87
List Price:  A$154.11
You save:  A$46.23
S$94.18
List Price:  S$134.55
You save:  S$40.36
HK$544.84
List Price:  HK$778.37
You save:  HK$233.53
CHF 61.96
List Price:  CHF 88.52
You save:  CHF 26.55
NOK kr774.61
List Price:  NOK kr1,106.63
You save:  NOK kr332.02
DKK kr496.47
List Price:  DKK kr709.28
You save:  DKK kr212.80
NZ$118.87
List Price:  NZ$169.82
You save:  NZ$50.95
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,391.40
List Price:  ৳11,988.23
You save:  ৳3,596.83
₹5,927.32
List Price:  ₹8,467.97
You save:  ₹2,540.64
RM312.91
List Price:  RM447.04
You save:  RM134.12
₦116,564.84
List Price:  ₦166,528.34
You save:  ₦49,963.50
₨19,514.20
List Price:  ₨27,878.62
You save:  ₨8,364.42
฿2,413.95
List Price:  ฿3,448.65
You save:  ฿1,034.70
₺2,432.13
List Price:  ₺3,474.63
You save:  ₺1,042.49
B$424.23
List Price:  B$606.07
You save:  B$181.84
R1,268.52
List Price:  R1,812.25
You save:  R543.73
Лв130.10
List Price:  Лв185.87
You save:  Лв55.76
₩98,223.31
List Price:  ₩140,325.03
You save:  ₩42,101.71
₪254.29
List Price:  ₪363.29
You save:  ₪108.99
₱4,101.97
List Price:  ₱5,860.21
You save:  ₱1,758.24
¥10,501.82
List Price:  ¥15,003.24
You save:  ¥4,501.42
MX$1,426.41
List Price:  MX$2,037.82
You save:  MX$611.40
QR256.18
List Price:  QR365.99
You save:  QR109.80
P959.98
List Price:  P1,371.46
You save:  P411.47
KSh9,063.70
List Price:  KSh12,948.70
You save:  KSh3,885
E£3,480.76
List Price:  E£4,972.73
You save:  E£1,491.96
ብር8,895.77
List Price:  ብር12,708.79
You save:  ብር3,813.02
Kz63,954.60
List Price:  Kz91,367.63
You save:  Kz27,413.03
CLP$68,503.41
List Price:  CLP$97,866.21
You save:  CLP$29,362.80
CN¥509.97
List Price:  CN¥728.56
You save:  CN¥218.59
RD$4,243.37
List Price:  RD$6,062.22
You save:  RD$1,818.84
DA9,361.89
List Price:  DA13,374.70
You save:  DA4,012.81
FJ$158.82
List Price:  FJ$226.89
You save:  FJ$68.07
Q542.41
List Price:  Q774.91
You save:  Q232.49
GY$14,692.16
List Price:  GY$20,989.70
You save:  GY$6,297.54
ISK kr9,697.81
List Price:  ISK kr13,854.61
You save:  ISK kr4,156.80
DH702.12
List Price:  DH1,003.07
You save:  DH300.95
L1,280.81
List Price:  L1,829.81
You save:  L549
ден4,090.50
List Price:  ден5,843.82
You save:  ден1,753.32
MOP$562.78
List Price:  MOP$804
You save:  MOP$241.22
N$1,276.46
List Price:  N$1,823.60
You save:  N$547.13
C$2,583.91
List Price:  C$3,691.46
You save:  C$1,107.55
रु9,517.46
List Price:  रु13,596.96
You save:  रु4,079.49
S/262.55
List Price:  S/375.10
You save:  S/112.54
K283.40
List Price:  K404.87
You save:  K121.47
SAR262.98
List Price:  SAR375.70
You save:  SAR112.72
ZK1,890.30
List Price:  ZK2,700.55
You save:  ZK810.24
L331.26
List Price:  L473.26
You save:  L141.99
Kč1,679.26
List Price:  Kč2,399.05
You save:  Kč719.78
Ft27,556.13
List Price:  Ft39,367.58
You save:  Ft11,811.45
SEK kr770.01
List Price:  SEK kr1,100.06
You save:  SEK kr330.05
ARS$70,784.44
List Price:  ARS$101,124.97
You save:  ARS$30,340.52
Bs485.20
List Price:  Bs693.18
You save:  Bs207.97
COP$310,826
List Price:  COP$444,056.18
You save:  COP$133,230.17
₡35,673.98
List Price:  ₡50,965.01
You save:  ₡15,291.03
L1,777.02
List Price:  L2,538.71
You save:  L761.69
₲548,127.41
List Price:  ₲783,072.72
You save:  ₲234,945.31
$U3,021.76
List Price:  $U4,316.99
You save:  $U1,295.22
zł285.75
List Price:  zł408.23
You save:  zł122.48
Already have an account? Log In

Transcript

All right, so picking up where we left off, we have two databases successfully created, but read into the at least right now I only need one. So I want to remove one of these databases. So there is a command in SQL. So just remove this line, or I just come in to talk. So you can just use a double dash, right and then what this does is render this line useless. So if you're used to other languages, like maybe C sharp JavaScript, you know you have that double slash, or you have that slash and each language has its own way.

So in SQL, we actually just use a double dash. All right, I want you to see that line turning green. If you are using the default coloring scheme, then you will know that this line is not going to have any bearing on anything once you click Execute. So we can go to the next line, and we will want to delete or in this case, drop it in SQL nomenclature, drop or database, no, I want to warn you be very, very careful and deliberate when you are going to run this and execute this command. Because dropping a database is an irreversible, there's no Recycle Bin, there is no recovering method, or there are a few books at this stage. We're not ready for those.

So be very, very careful and very, very deliberate in writing and further executing this command, so we're going to say a drop database. And then as you go along, you start seeing that there's a pattern and I notice I'm not writing it in all caps. Once again, it is not case sensitive. So drop database, and then we have to specify the database name. So we want to drop school underscore test. So I'll just school underscore test and we see here that the editor is actually kind of picking up on the Once you may want to do, so it's kind of completing what it is that it thinks you want to do based on the information it has available to you.

So it makes it pretty easy to write complex statements in a very short while. So we want to drop the database called school underscore test. And then I'm going to execute that, once again, be very deliberate and careful when doing this, because SQL will not ask you if you're sure you want to delete this item. All right, SQL is just going to see that sorry, SQL Management Studio is just going to say this is the command I got I'm going to execute it. So when I click Execute, there we go. But we still see the database listed here.

So as usual, we just click here and refresh and then we see that there is no longer any trace of school underscore test. And if I attempt to execute this again, then I will get an arrow seen that I cannot drop it because it does not exist or you don't have friends. permission. We know we have permission, we know we just did it. So we know that it's because it does not exist in the same way. And a quick way to comment in SQL Management Studio is to press the Ctrl key and see, as a matter of fact, in the class notes, I have a bunch of keyboard shortcuts that can help you get along quickly and move along in the editor with with minimal effort.

All right, I love keyboard shortcuts. So we can say create database and I will try to create school. Well, we know we already have school so I just want to show you the type of error that you would see. And then it says database school already exists. Please choose a different name so we can't have two databases with the same name. If you need two identical named ones, you know you can use your underscore or you can add a number numbers are acceptable.

Of course the character sets there are strict rules are owned at budds We have infinitely many characters at our disposal. So we can always mix and match and be unique. Alright, so that was how we go about removing a database. Next we look at how we go about creating what we call tables in our database.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.