(6) MySQL data operation DML

Source: Internet
Author: User

(1) Insert: Insert Data

Sequentially inserting data
Insert into table name values (value 1, value 2, value 3);
Specify fields to insert data
Insert into table name (Field 1, Field 2, Field 3) VALUES (value 1, value 2, value 3);
Inserting more than one record
Insert into table name values (value 1, value 2, value 3), (value 1, value 2, value 3);
Insert Query Results
Insert INTO Table 1 Select (Field 1, field N) from table 2 where condition;

mysql> insert into student values(1,‘jack‘,‘m‘,20);              \\顺序插入数据mysql> insert into student(name,age) values(‘bob‘,21);              \\指定字段插入数据mysql> insert into student values(6,‘jex‘,‘m‘,21),(7,‘bob1‘,‘f‘,22);    \\插入多条记录mysql> insert into student_his select * from student where name = ‘robby‘;  \\插入查询结果
(2) Update: Updating data

Update table name set field 1 = new value 1, field 2 = new value 2 where condition;

mysql> update mysql.user set authentication_string=password(‘redhat‘) where user=‘root‘ and host=‘localhost‘; \\password()是一个函数mysql> flush privileges;
(3) Delete: delete data

Delete from table name where condition;
Delete from table name; Delete all data from a table

(6) MySQL data operation DML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.