1
00:00:02,070 --> 00:00:03,530
So time to add some data

2
00:00:03,530 --> 00:00:05,100
into this restaurant's table,

3
00:00:05,100 --> 00:00:07,313
because that's what we created it for.

4
00:00:08,210 --> 00:00:12,280
Now, for this, we want to execute another SQL statement

5
00:00:12,280 --> 00:00:15,200
this time, a statement that targets this table

6
00:00:15,200 --> 00:00:16,860
and inserts data.

7
00:00:16,860 --> 00:00:19,370
And now it's the first time that we'll write

8
00:00:19,370 --> 00:00:23,060
a SQL statement from the ground up without configuring it

9
00:00:23,060 --> 00:00:25,423
through some graphical user interface first.

10
00:00:26,720 --> 00:00:29,750
For that, I'll close those tabs here,

11
00:00:29,750 --> 00:00:33,130
and then click this button here to create a new tab

12
00:00:33,130 --> 00:00:35,920
for defining a SQL statement.

13
00:00:35,920 --> 00:00:39,080
And in here, you can write your own SQL code

14
00:00:39,080 --> 00:00:42,460
and then execute it by clicking this flash here.

15
00:00:42,460 --> 00:00:46,580
Now, you can write the same statements we had before here.

16
00:00:46,580 --> 00:00:49,070
So we could again run create table

17
00:00:49,070 --> 00:00:53,360
if we wanted to add a new table to our database.

18
00:00:53,360 --> 00:00:55,220
But here, I don't want to do that.

19
00:00:55,220 --> 00:00:58,780
Instead, I want to insert data into a table

20
00:00:58,780 --> 00:01:03,780
and that can be done by using the Insert Into command.

21
00:01:04,739 --> 00:01:08,570
So by combining the keywords Insert and Into,

22
00:01:08,570 --> 00:01:12,960
these are built in SQL commands that tell the SQL server

23
00:01:12,960 --> 00:01:15,883
that we want to insert some data into some table.

24
00:01:17,040 --> 00:01:18,780
Now, the first piece of information

25
00:01:18,780 --> 00:01:21,810
you need to provide after Insert Into

26
00:01:21,810 --> 00:01:23,460
is then the table name,

27
00:01:23,460 --> 00:01:25,720
where the data should be inserted.

28
00:01:25,720 --> 00:01:27,373
In this case, restaurants.

29
00:01:28,560 --> 00:01:30,840
Either between these backticks,

30
00:01:30,840 --> 00:01:33,870
or if there are no special characters in the table name

31
00:01:33,870 --> 00:01:34,943
just like this.

32
00:01:36,310 --> 00:01:40,453
You can also again say restaurant_finder.restaurants,

33
00:01:42,210 --> 00:01:46,000
but normally, this database should already be selected

34
00:01:46,000 --> 00:01:48,470
and then for queries should automatically run

35
00:01:48,470 --> 00:01:50,110
against this database.

36
00:01:50,110 --> 00:01:52,123
So does this not required here.

37
00:01:53,000 --> 00:01:56,320
Now, as a next step, after defining the table name

38
00:01:56,320 --> 00:01:59,100
where you want to insert values into,

39
00:01:59,100 --> 00:02:01,530
you now need a pair of parentheses.

40
00:02:01,530 --> 00:02:03,310
And between those parentheses,

41
00:02:03,310 --> 00:02:07,363
you refer to the columns into which you want to insert data.

42
00:02:08,270 --> 00:02:11,330
Of course, we want to provide data for all the columns

43
00:02:11,330 --> 00:02:15,070
except for the ID, because that will be set and incremented

44
00:02:15,070 --> 00:02:16,583
automatically as we learned.

45
00:02:17,640 --> 00:02:19,560
So here, we then repeat the column names

46
00:02:19,560 --> 00:02:21,540
into which we want to insert data.

47
00:02:21,540 --> 00:02:25,633
In this case, name and then separated by a comma, type.

48
00:02:27,120 --> 00:02:29,630
So now we're saying that for the new record

49
00:02:29,630 --> 00:02:31,240
that we are about to add,

50
00:02:31,240 --> 00:02:34,230
we want to set values for these two fields,

51
00:02:34,230 --> 00:02:35,723
for these two columns.

52
00:02:36,890 --> 00:02:39,760
But we haven't defined which values should be stored

53
00:02:39,760 --> 00:02:41,440
in this record now.

54
00:02:41,440 --> 00:02:44,070
And for that, we now use the values keyword.

55
00:02:44,070 --> 00:02:47,290
And then after that, again, between parentheses,

56
00:02:47,290 --> 00:02:50,750
the values for these columns in the same order

57
00:02:50,750 --> 00:02:53,000
as you listed the columns here.

58
00:02:53,000 --> 00:02:54,800
So I have name, type.

59
00:02:54,800 --> 00:02:58,250
So I first provide the name value and then the type value

60
00:02:58,250 --> 00:03:00,570
between those brackets here.

61
00:03:00,570 --> 00:03:03,890
And the names should be some text and therefore,

62
00:03:03,890 --> 00:03:07,240
just as in JavaScript, we use quotes here,

63
00:03:07,240 --> 00:03:11,193
double quotes or single quotes, both works.

64
00:03:12,100 --> 00:03:14,440
And then we could say the first restaurant is called

65
00:03:14,440 --> 00:03:19,263
the Web Dev Mealery, super amazing name,

66
00:03:20,130 --> 00:03:23,360
and the type of the restaurant separated by a comma,

67
00:03:23,360 --> 00:03:27,900
and also a string could be Italian,

68
00:03:27,900 --> 00:03:30,833
or German, whatever you want.

69
00:03:31,970 --> 00:03:36,070
And that's now a finished command for inserting a new record

70
00:03:36,070 --> 00:03:38,603
as it's called into this restaurant's table.

71
00:03:39,840 --> 00:03:43,300
We can now execute it by clicking that flash.

72
00:03:43,300 --> 00:03:46,210
And if we do so, down there at the bottom,

73
00:03:46,210 --> 00:03:48,430
we see whether it succeeded or not.

74
00:03:48,430 --> 00:03:50,550
If you got a green check mark, it worked,

75
00:03:50,550 --> 00:03:54,270
and you'll see that one row was affected by this command,

76
00:03:54,270 --> 00:03:57,063
which makes sense because a new row was added.

77
00:03:58,400 --> 00:04:01,770
But now, it would also be nice to see that new row.

78
00:04:01,770 --> 00:04:03,725
And for that, we can run another command

79
00:04:03,725 --> 00:04:07,923
to query the data that's inside of a table.

