1
00:00:00,210 --> 00:00:05,650
So another thing we can do, which hopefully we don't want to do that often, is drop a database.

2
00:00:05,670 --> 00:00:10,020
Now, this is something you actually want to be quite careful with once you have databases that have

3
00:00:10,020 --> 00:00:10,920
real data.

4
00:00:11,130 --> 00:00:14,730
We don't at the moment, ours are completely empty so we can play around with it.

5
00:00:14,850 --> 00:00:19,120
But this will remove a database entirely and all of its contents.

6
00:00:19,140 --> 00:00:20,310
So drop database.

7
00:00:20,310 --> 00:00:25,650
And then once again, you replace that with the name of a database that exists like soap store.

8
00:00:25,830 --> 00:00:26,760
So let's try it.

9
00:00:26,760 --> 00:00:27,750
I'll do it in the command line.

10
00:00:27,750 --> 00:00:30,680
First, let's delete slime store.

11
00:00:30,690 --> 00:00:36,660
So drop database and then I have to spell it correctly and capitalize it like that.

12
00:00:37,380 --> 00:00:43,110
It says, okay, let's do a select or rather show databases.

13
00:00:44,340 --> 00:00:45,390
It's no longer here.

14
00:00:45,690 --> 00:00:51,030
If I go back to my workbench, slime store is right here because this is sort of out of sync.

15
00:00:51,030 --> 00:00:52,260
I have to refresh.

16
00:00:52,770 --> 00:00:54,360
And now we see it's gone.

17
00:00:54,570 --> 00:01:00,960
If I head over to another tool DB gate, which I think I'm going to lean more on because you can actually

18
00:01:00,960 --> 00:01:03,030
read the text here.

19
00:01:03,030 --> 00:01:07,130
Compared to this, my SQL gives me no way of increasing this font size.

20
00:01:07,140 --> 00:01:08,850
It's kind of insane anyway.

21
00:01:09,420 --> 00:01:11,040
It's the same concept, right?

22
00:01:11,040 --> 00:01:14,940
I've got slime store, but if I refresh, it's gone.

23
00:01:15,660 --> 00:01:16,290
Okay.

24
00:01:16,380 --> 00:01:19,650
So I can also drop a database from within one of these.

25
00:01:20,070 --> 00:01:21,300
All I need to do.

26
00:01:21,330 --> 00:01:22,950
Let's say I wanted to drop this database.

27
00:01:22,950 --> 00:01:25,110
Here is write a script.

28
00:01:25,110 --> 00:01:33,030
So I'm going to click the plus sign and just run drop database, pet underscore shop, put my semicolon

29
00:01:33,030 --> 00:01:36,060
in there, and then I'm going to click Execute.

30
00:01:37,360 --> 00:01:38,740
And it finished.

31
00:01:38,770 --> 00:01:39,820
I'll refresh.

32
00:01:40,090 --> 00:01:41,380
Pet shop is gone.

33
00:01:41,410 --> 00:01:42,670
I refresh over here.

34
00:01:42,700 --> 00:01:43,960
Pet shop is gone.

35
00:01:43,960 --> 00:01:45,520
And if I do another show?

36
00:01:45,520 --> 00:01:47,020
Databases, Pet shop.

37
00:01:47,020 --> 00:01:48,610
Once again, it's gone.

38
00:01:48,970 --> 00:01:50,950
All right, so that's how we can draw up a database.

39
00:01:50,980 --> 00:01:52,630
Of course you want to be careful with that.

40
00:01:52,870 --> 00:01:56,290
The next thing we need to do is use a database.

41
00:01:56,290 --> 00:02:00,700
We can create empty ones, We can delete databases, but we need to use them.

42
00:02:00,700 --> 00:02:04,480
And use is the actual command that we're going to use.

43
00:02:04,720 --> 00:02:09,729
It's uppercase used, although it doesn't have to be uppercase, but it's another one of those SQL keywords

44
00:02:09,850 --> 00:02:13,480
and then a name of a database that currently exists.

45
00:02:13,480 --> 00:02:19,420
And this tells my SQL, we want to think of it as like double clicking on this database, selecting

46
00:02:19,420 --> 00:02:22,120
it as what we want to be working inside of.

47
00:02:22,270 --> 00:02:24,910
So we can have all these different databases.

48
00:02:24,910 --> 00:02:31,300
But when it comes time to insert information or find information or delete information or create new

49
00:02:31,300 --> 00:02:35,260
tables, we have to tell my SQL where we are.

50
00:02:35,350 --> 00:02:37,290
So the way that we do that is use.

51
00:02:37,300 --> 00:02:43,390
So let's do use chicken underscore coupe and it tells us database changed.

52
00:02:43,480 --> 00:02:46,180
You selected your working in a new database.

53
00:02:46,300 --> 00:02:53,020
Now how do we know that other than seeing database changed, we have this other command select database

54
00:02:53,020 --> 00:02:54,460
with parentheses.

55
00:02:54,490 --> 00:02:59,560
I don't use this very often, but when we're starting out, it's a great way to know that we're doing

56
00:02:59,560 --> 00:03:00,550
things correctly.

57
00:03:00,550 --> 00:03:05,500
I should see chicken coop and I do it says this is your current database, chicken coop.

58
00:03:05,950 --> 00:03:09,430
So if I were to make a new database, create database.

59
00:03:10,180 --> 00:03:13,090
How about t shop?

60
00:03:13,090 --> 00:03:18,220
I don't know why everything has to be a shop, but sure, t shop and I run select database.

61
00:03:18,220 --> 00:03:20,440
I'm not using that new database.

62
00:03:20,440 --> 00:03:23,680
I made it, but I'm not actually working inside of it.

63
00:03:23,890 --> 00:03:27,490
I have to then run use t shop.

64
00:03:28,890 --> 00:03:30,990
And then it will tell me the database changed.

65
00:03:30,990 --> 00:03:35,140
But if I want to know for sure what it changed to, I select database with parentheses.

66
00:03:35,160 --> 00:03:36,120
Tea Shop.

67
00:03:36,750 --> 00:03:46,230
Now when we're over here in workbench or in DB Gate, any of these graphical interfaces I can write

68
00:03:46,230 --> 00:03:47,910
use, I can say use.

69
00:03:48,570 --> 00:03:49,530
Let's refresh.

70
00:03:49,620 --> 00:03:51,180
I should see t shop.

71
00:03:51,180 --> 00:03:57,100
Yeah, I can say use t shop and execute this script if I wanted to.

72
00:03:57,810 --> 00:03:59,400
And that's fine.

73
00:04:00,090 --> 00:04:06,000
And then if I wanted to select database to prove that it's working, let's run the script again.

74
00:04:06,660 --> 00:04:10,500
It says your database is t shop OC, so that's fine.

75
00:04:10,500 --> 00:04:14,780
But there's actually an easier way to use a database.

76
00:04:14,790 --> 00:04:16,950
It's as simple as double clicking.

77
00:04:16,950 --> 00:04:24,300
So if I have a if I double click on chicken coop and I get rid of that use and I just select the database,

78
00:04:25,080 --> 00:04:27,330
it says you're working with chicken coop.

79
00:04:27,540 --> 00:04:30,510
So if I double click on t shop, I run the same thing.

80
00:04:30,540 --> 00:04:33,890
Now it says t shop, same thing over in this DB gate.

81
00:04:33,900 --> 00:04:40,140
If I select chicken coop or Let's do t shop and then I click the plus sign, I have a new script and

82
00:04:40,140 --> 00:04:42,030
you'll see up here it says t shop.

83
00:04:42,030 --> 00:04:44,340
So this is using t shop.

84
00:04:44,340 --> 00:04:52,530
If I do select database and I run this, we see t shop, right?

85
00:04:52,530 --> 00:04:54,840
If I instead went over to chicken coop.

86
00:04:55,320 --> 00:05:00,840
Now this is still going to say t shop up there, but if I do chicken coop plus sign and I do the same

87
00:05:00,840 --> 00:05:03,750
thing, select database.

88
00:05:04,140 --> 00:05:07,740
We'll be working in one database for a lot of the course.

89
00:05:07,740 --> 00:05:09,300
So it's not a big deal to change.

90
00:05:09,300 --> 00:05:10,290
We don't need to change.

91
00:05:10,290 --> 00:05:14,460
But if I run this, execute it says chicken coop.

92
00:05:14,490 --> 00:05:16,680
All right, so that's how we can use a database.

93
00:05:16,680 --> 00:05:22,920
It's like clicking into it, selecting it, telling my SQL, this is the the one database I want to

94
00:05:22,920 --> 00:05:24,510
be interacting with right now.

95
00:05:24,720 --> 00:05:27,990
Of course, we're not really interacting with them, but we are selecting them.

96
00:05:27,990 --> 00:05:28,980
We're using them.

97
00:05:28,980 --> 00:05:32,640
Next up, we're going to learn all about putting stuff in a database.

