Pages

Wednesday, 15 June 2016

Data Manipulation Language (DML) Statements - MySQL Data Manipulation and Query Statements

DML COMMANDS:  (Data Manipulation Language) statements are statements to change data values in database tables.  

There are 3 primary DML statements:
INSERT –  Inserting new rows into database tables.
UPDATE – Updating existing rows in database tables.
DELETE – Deleting existing rows from database tables.

INSERT: If a column is defined with a default value in a table, you can use the key word DEFAULT in the INSERT statement to take the default value for that column.

To insert data into MySQL table, you would need to use SQL INSERT INTO command.
To insert string data types, it is required to keep all the values into double or single quote.
For example:- “value

UPDATE: If you want to update some values in one row or multiple rows in a table, you can use the UPDATE statement. The tutorial script below shows a good example:
Where existing data in a MySQL table needs to be modified. You can do so by using SQL UPDATE This will modify any field value of any MySQL table.

DELETE: If you want to delete an existing row from a table, you can use the DELETE statement with a WHERE clause to identify that row. Here is good sample of DELETE statements:

  • If WHERE clause is not specified, then all the records will be deleted from the given MySQL table.
  • You can specify any condition using WHERE clause.
  • You can delete records in a single table at a time.
  • The WHERE clause is very useful when you want to delete selected rows in a table.

If you want to delete a record from any MySQL table, then you can use SQL command DELETE FROM

No comments:

Post a Comment