SQL Data Manipulation Language (DML) INSERT, UPDATE and DELETE statements

The language SQL (Structured Query Language) is a database language that allows you to access databases.

This language is used to access the main databases existing today such as SQL Server Microsoft or Oracle database, of course the syntax between these two databases may have some differences, but the basic commands are practically the same.

 

SQL Instruções DML (Data Manipulation Language)  INSERT, UPDATE e DELETE
SQL Data Manipulation Language (DML) INSERT, UPDATE and DELETE statements

DML Instructions (Data Manipulation Language)

Data Manipulation Language – These are commands that modify the contents of tables. The most common commands are INSERT, UPDATE and DELETE.

INSERT – Inserts rows of data into a column. See usage example:

  • INSERT INTO customers VALUES (1,'Jose',30,'(11)5555-5555')

Explanation (MYSQL bank)

  • INSERT INTO – Command to enter data
  • customers – table name
  • VALUES – Values that will be entered
  • 1,'Jose',30,'(11)5555-5555' – Let's say that in the table customers contains the following columns: code, name, age, phone. The data (1,'Jose',30, '(11)5555-5555') matches the data in each column.

 

UPDATE – Updates data in a table. See usage example:

  • UPDATE patient SET name='John' ONDE code=1 AND age=30

Explanation (MYSQL bank)

Update (UPDATE) the name field to (SET) João when (WHERE) the code is equal to 1 and (AND) the age is equal to 30

  • UPDATE – Command to update data
  • SET – what will be changed
  • ONDE – condition
  • AND – adds other conditions

Note that the name Jose has been changed to John.

 

DELETE – Deletes data from a table. See usage example:

  • DELETE FROM patient ONDE name='John'

Explanation (MYSQL bank)

  • DELETE – command to delete
  • FROM – in, indicates the table
  • ONDE – condition that indicates what will be deleted

Note that in DELETE you can still use AND if you want to add more conditions.

 2,628 Total Visualizações,  6 Visualizações Hoje

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.