Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,256 --> 00:00:05,120
In the last video we learnt how to update rows in a table
1
2
00:00:05,376 --> 00:00:11,520
now let us see how to delete one or more rows from a Table
2
3
00:00:11,776 --> 00:00:17,920
To delete rows, delete query is used. The syntax of delete query is
3
4
00:00:18,176 --> 00:00:18,688
Delete from
4
5
00:00:19,200 --> 00:00:20,480
Mention the table name
5
6
00:00:20,992 --> 00:00:22,528
and then give the condition
6
7
00:00:23,040 --> 00:00:24,576
for the rows to be deleted
7
8
00:00:25,088 --> 00:00:27,136
Condition will be given again using the
8
9
00:00:27,392 --> 00:00:28,416
Where clause
9
10
00:00:29,184 --> 00:00:30,464
Let us see some example
10
11
00:00:33,024 --> 00:00:34,816
If you want to delete a single row
11
12
00:00:35,328 --> 00:00:36,608
We can just run a query
12
13
00:00:36,864 --> 00:00:38,912
to delete from customer table
13
14
00:00:39,168 --> 00:00:40,704
Where customer ID is
14
15
00:00:41,472 --> 00:00:41,984
six
15
16
00:00:43,008 --> 00:00:44,800
If you want to delete multiple rows
16
17
00:00:45,056 --> 00:00:45,568
Say
17
18
00:00:45,824 --> 00:00:49,664
If you want to delete all the customers who are less than 25 years old
18
19
00:00:49,920 --> 00:00:52,480
We will write delete from customers
19
20
00:00:52,736 --> 00:00:54,528
From customer table where
20
21
00:00:54,784 --> 00:00:56,576
Age is less than 25
21
22
00:00:57,600 --> 00:00:59,904
If you want to delete all the rows of the table
22
23
00:01:00,416 --> 00:01:01,184
we will use
23
24
00:01:01,696 --> 00:01:02,464
Delete
24
25
00:01:03,232 --> 00:01:05,792
From customer table and not mention any condition
25
26
00:01:07,072 --> 00:01:09,888
Let's go to PG admin and write these 3 queries
26
27
00:01:10,656 --> 00:01:15,264
Now let us delete the customer with Customer Id 6
27
28
00:01:15,776 --> 00:01:18,080
We'll write delete from
28
29
00:01:20,128 --> 00:01:24,480
Customer table
29
30
00:01:24,736 --> 00:01:26,528
Where
30
31
00:01:26,784 --> 00:01:29,088
Cust ID
31
32
00:01:29,600 --> 00:01:33,184
Is equal to 6
32
33
00:01:34,208 --> 00:01:36,000
Let us run this
33
34
00:01:38,560 --> 00:01:44,704
And let us see the result
34
35
00:01:44,960 --> 00:01:51,104
If you remember earlier we had 10 records after deleting this one record
35
36
00:01:51,360 --> 00:01:52,128
We'll be having
36
37
00:01:52,640 --> 00:01:54,944
9 records
37
38
00:02:00,832 --> 00:02:05,696
We have 8 records in the result because 2 customers had customer ID
38
39
00:02:05,952 --> 00:02:06,464
Six
39
40
00:02:08,256 --> 00:02:08,768
Now
40
41
00:02:09,536 --> 00:02:12,096
If you want to delete, all the customers
41
42
00:02:13,120 --> 00:02:15,168
Whose age is more than 30 years
42
43
00:02:15,424 --> 00:02:16,960
So if we look at the data
43
44
00:02:17,472 --> 00:02:19,776
Customer with customer ID 1
44
45
00:02:20,544 --> 00:02:22,336
And customer ID
45
46
00:02:22,592 --> 00:02:23,104
8
46
47
00:02:23,872 --> 00:02:25,408
Customer ID 4
47
48
00:02:26,432 --> 00:02:28,480
These three customers have
48
49
00:02:29,760 --> 00:02:34,880
age more than 30 years. Let us delete these three customers from our database
49
50
00:02:35,648 --> 00:02:40,512
Delete from customer table
50
51
00:02:43,840 --> 00:02:47,168
Where age
51
52
00:02:47,424 --> 00:02:48,960
is equal to
52
53
00:02:49,984 --> 00:02:53,824
age greater than 30. Let's run this.
53
54
00:02:57,408 --> 00:02:58,688
It ran successfully
54
55
00:02:58,944 --> 00:03:00,224
Let us run the
55
56
00:03:01,504 --> 00:03:03,040
Select query
56
57
00:03:03,296 --> 00:03:04,832
You can see only
57
58
00:03:05,088 --> 00:03:06,368
5 remain
58
59
00:03:06,624 --> 00:03:12,256
earlier we had 8. 3 customers had age more than 30. Now no customer has age more than 30
59
60
00:03:13,792 --> 00:03:17,120
You can delete all the rows of this table
60
61
00:03:18,144 --> 00:03:19,168
To do that
61
62
00:03:19,424 --> 00:03:21,984
we will not specify any condition we will just
62
63
00:03:22,240 --> 00:03:23,776
Tell it to delete
63
64
00:03:24,288 --> 00:03:27,872
From customer table and that's it
64
65
00:03:29,664 --> 00:03:34,016
If we run this query everything from the table will be deleted
65
66
00:03:34,784 --> 00:03:37,856
Let us run this select command
66
67
00:03:39,648 --> 00:03:41,696
You can see only column names are there
67
68
00:03:41,952 --> 00:03:42,720
That's all
68
69
00:03:42,976 --> 00:03:45,536
what this table now has, it has no rows
69
70
00:03:46,304 --> 00:03:47,328
No data in it
70
71
00:03:49,120 --> 00:03:51,168
So that's how you delete data from a Table
71
72
00:03:52,192 --> 00:03:53,216
In the next lecture
72
73
00:03:53,728 --> 00:03:56,032
We will learn, how to change
73
74
00:03:56,288 --> 00:03:56,800
The
74
75
00:03:57,056 --> 00:03:58,336
Structure of the table
75
76
00:03:58,592 --> 00:04:03,712
Structure of the table is comprised of the columns column names or the constraints
76
77
00:04:03,968 --> 00:04:10,112
added to the columns, all these constitute the structure of the table and we will learn how to change the structure of the table
5567
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.