(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