0:02 [Music] 0:06 thank you 0:09 [Music] 0:11 Hello friends welcome back to our 0:13 Channel 0:13 so in today's session we'll discuss 0:15 about two more commands in SQL that is a 0:19 drop and truncate 0:23 so a drop command is used to delete the 0:27 complete table from the database whereas 0:29 truncate command will delete the data 0:33 from the table not the table the data 0:35 from the table 0:37 so let us see the syntax and then we'll 0:40 execute the same in the SQL 0:43 so the first one is a drop command and 0:47 both are both comes under the data 0:49 definition language commands Okay so 0:52 drop command which is a ddl command 0:55 and the syntax is 0:58 drop 1:00 table followed by table name so it will 1:04 delete the complete table okay see here 1:09 it deletes 1:13 complete table 1:16 from the database from the database so 1:20 we know that the database consists of a 1:22 lot of tables so in order to delete the 1:24 table the syntax is drop table table 1:27 name 1:29 okay 1:34 the ddl command and it deletes 1:41 complete data from the table so the 1:46 table will not be deleted but it will 1:47 delete the data from the table so the 1:50 Syntax for this one is a truncate 1:53 table 1:54 name 1:57 table name right so let us execute these 2:00 two commands in the MySQL so let us open 2:03 the MySQL command line 2:05 so it will prompt for the password so 2:07 use the password 2:09 I'll 2:11 clear the screen now use the database 2:15 YouTube because we are going we are 2:16 using this YouTube and in this YouTube 2:19 we are having the tables let us check 2:22 tables so we are having only one table 2:24 that is a student 2:25 right so if you want to delete the data 2:28 so let us check whether this one having 2:31 the data or not so select start from 2:34 student there is an empty table 2:36 so let us insert some data so insert 2:40 let us check the 2:43 description 2:47 so that will get the complete structure 2:50 so we need to give all these values so 2:52 I'll insert 2:56 or or first let us see the drop table so 3:00 drop 3:01 table 3:02 student so it will completely delete the 3:06 table from the database see query okay 3:08 zero rows affected and now you can see 3:10 show databases or show tables so it will 3:13 be an empty set because previously we 3:16 are having a student table so in the 3:18 YouTube database if you execute this 3:21 issue tables command you will get the 3:24 table student 3:25 but we have deleted the table so if the 3:30 table consists of data then also the 3:31 table will be deleted the drop table 3:34 table name will completely deletes the 3:36 table from the database now once again 3:39 we'll create a table and we'll check 3:41 with the truncate function so create 3:44 table 3:46 student let us uh 3:49 take some three attributes Sid which is 3:52 of a integer s name 3:55 which is of where care 3:59 of authority 4:00 and some percentage which is of a float 4:04 and use a primary key it's not required 4:07 but we'll use this one primary key as ID 4:11 so a table has been created now if You 4:14 observe short tables so there is a one 4:17 table with a student so let us insert 4:19 some values insert into student 4:23 values so let us take 1 0 1 4:28 Sandeep 4:30 99 4:34 so one row affected 4:37 and see one zero two 4:42 sarathi 4:46 96 so again 4:49 one zero three 4:54 ramu 4:56 sorry 4:59 one zero three 5:03 ramu 5:05 with 93 5:08 right so now you can select a star from 5:11 student you can get the data so there 5:14 are three rows now use a truncate method 5:17 truncate table table name student so it 5:22 will delete all the data from the table 5:25 so you can observe the 5:27 tables so the table exists okay the 5:30 table will not be deleted so if you use 5:33 a truncate command it will delete the 5:35 data inside the table but not the table 5:37 right so you can observe show tables 5:39 still the student table is available 5:40 here 5:41 but what about the rows inserted in the 5:45 student tables so select start from 5:47 student it will be the empty set because 5:49 all these through three rows will be get 5:52 deleted 5:53 for by using this truncate command 5:57 right so hope you understood this one a 5:59 simple commands drop to delete the table 6:02 truncate to delete the data 6:04 right so let's stop here so hope you 6:07 understood this uh ddl comment so uh if 6:11 you are having any doubts regarding this 6:12 one feel free to post your doubts in the 6:13 comment section definitely I will try to 6:14 clarify all your doubts and if you 6:17 really enjoyed my session like my 6:18 session share my session with your 6:19 friends and don't forget to subscribe to 6:21 our Channel thanks for watching thank 6:23 you very much