Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MYSQL Learning Series-- DML sentences (1)

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report