MySQL Insert, Update and Delete Operations - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Community

MySQL Insert, Update and Delete Operations

Share This

In this tutorial we will discuss how insert, update and delete operations can be performed on a table.

Insert Queries

At the time of insertion, if you want to insert a tuple where values exist with respect to all the attributes, you can use the following syntax.


If the values of all the attributes are not known, you can also mention the name of the attributes for which you the data. The sequence of the attributes of the insert query is to be the same as the sequence of attributes of the table. Look into the following SQL queries to check it.


 
Select Queries

To select all the data you have in your table, you can use select queries as shown below:



If you want to select a specific set of attributes, you can write the query as follow:



Delete Queries

If you want to delete all the tuples of a table, the truncate query can be used. The following figure shows a truncate query for the above-mentioned table.



Similarly, if you want to perform a delete operation, you can also use a delete query.



Instead of deleting all the tuples, if you want to delete selective tuples based on some condition, you can use the where clause.



Update Queries


In this context, we will discuss how to update existing data in a table. Let us assume that in the above table, the year and volume information is wrong for Programming in Java book, hence the fields need to be updated.



Here, we can write SQL to update the required fields based on some conditions so that all the tuples are not modified.






Happy Exploring!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.