How to Delete one row in SQLHere, you will learn how to delete one row or record from a table in Structured Query Language. We can easily delete one record using the SQL DELETE statement. This statement also removes all the existing rows from the database tables. It also helps in removing the data from the SQL views. Once a row has been deleted from the table, that row cannot be recovered. The SQL syntax for deleting a specific row is given below: In this syntax, the WHERE clause specifies that record which you want to remove from the table. If you run the DELETE command without WHERE clause, the query will remove all the rows from the SQL table. If you want to remove the records permanently from the table, you have to follow the following steps one by one in the given order:
Now, we are going to explain the above steps with an example: Step 1: Create a DatabaseIn the Structured Query Language, creating a database is the first step for storing the structured tables in the database. Use the following SQL command to create a database: Suppose you want to create a College database. For this operation, you have to type the following command in Structured Query Language: Step 2: Create a Table and Insert the dataAfter database creation, you can create the table in the database with the help of the following syntax: Suppose you want to create the Student table with five columns in the College database. For this, you have to write the following query: Now, you have to insert the data in the table using the following syntax: You can easily insert the data of college students in the Student table using the following query in SQL: Step 3: View the Inserted DataAfter table creation and data insertion, you can view the inserted data of the Student table by typing the following query in your SQL application:
Step 4: Delete One Record from the tableThe following query deletes the record of the specific student from the above student table: Step 5: View the Table after DeletionTo check the result of the query executed in the 4th step, you have to use the following SELECT command in SQL:
As you can see that one row has been successfully deleted from the Student table based on the situation specified in the WHERE clause of the DELETE query. Delete Multiple Records from the tableIf you want to delete the multiple rows from the Students table, you have to write the below query in your SQL application: To check the result of the above query, you have to write the following SELECT query in SQL:
As we can see that more than one row has been deleted from the Student table according to the condition specified in the WHERE clause of the DELETE statement. Next TopicHow to Change the Column Value in SQL |