Get the App
SLTechnology News&Howtos  ›  Database  › 

MYSQL Learning Series-- DML sentences (1)

Shulou Source: shulou.com Published: 2022-06-01 02:47:38 09月12日 Update

Introduction:

Data manipulation language (Data Manipulation Language, DML) is a set of instructions responsible for running data access to database objects in SQL language. With INSERT, UPDATE and DELETE as the core, it represents insertion, update and deletion respectively. It is an instruction that must be used in the development of data-centric applications.

Practical operation

Before the operation, the creation of some databases and tables will not be discussed in detail here. You can read the MYSQL learning series-- DDL statement, which I wrote earlier.

The query uses the select * from table name; the prerequisite is to enter the database

The query is empty because there is no data inserted on my side, so let's insert the data.

1) insert record

1 > insert record

Syntax: insert into table name (field 1, field 2, field 3, field n) values (value 1, value 2, value 3, value n)

Use the desc table name to see which fields are available

You don't have to specify a field name, but the order after values should be the same as the sort of fields, and the number of fields should be the same.

2 > insert multiple pieces of data at a time

Insert into table name (field 1, field 2, field 3, field n) values (value 1, value 2, value 3, value n), (value 1, value 2, value 3, value n)

2) Update the record

1 > Update a table

Update table name set field 1 = value 1, field 2 = value 2. Field n = value n [where condition]

We changed the field name (name) of number=3 to abc

2 > updating data in multiple tables

Let's create a new table with the name set to student1

Then we change the abc of studet to hhh and the xiaolan of table student1 to ywboy

3) Delete records

1 > Delete data from a single table

Delete from table name [where condition]

Let's try to delete the person named hhh from the student table.

2 > Delete data from multiple tables

Delete Table 1, Table 2. Table n from Table 1, Table 2. Table n [where condition]

Regardless of whether it is a single table or multiple tables, all records in the table will be deleted without where conditions, so be careful when doing so.

You can try this by yourselves.

Tags: Fields data conditions updates instructions databases consistency names multiple languages attempts queries statements learning next one-time no representatives premises multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information NVidia Linux Shulou Tech Info