/*--Google Analytics--*/ /*--Google Analytics--*/

Useful INSERT, UPDATE & DELETE Queries that must be Glanced

The Following Query is for the people who have some basic idea about databases, tables, SELECT statements, Sub-Queriesand these are some of the useful statements, mainly used in developing real time projects, so just remember their usage.


INSERT


INSERT Customers (FirstName, LastName, City, State, PIN) VALUES ('John', 'Wesley', 'Hyderabad', 'AP', '500020')



Care Should be taken that number of coloumns is equal to the number of values, not more-not less. No need to have all the coloumns but all the coloumns which are not nulls are mandatory.


Care should be taken in matching the data types. No need to put single quotes for numbered data types but all other datatypes should be single quoted.



UPDATE


UPDATE Customers SET City = 'Delhi', PIN = '552520' WHERE LastName = 'Wesley'



Updates are Very very Dangerous among all Queries, so use them with extreme caution. If u leave the WHERE clause u will be in big trouble. So first check ur WHERE clause with a SELECT statement, before performing an UPDATE.



DELETE


DELETE Customers WHERE LastName = 'Wesley'



Deletes are aslso very dangerous, so take the same precautions mentioned for UPDATES. Note that some rows cannot be deleted which are related with foreign keys.



Hope this small Article is useful. Our tutorials are short and simple but Useful.


Use UPDATES and DELETES with extreme caution.


Next Lesson Is About Stored Procedures

0 comments:

Post a Comment