新疆做網(wǎng)站多少錢seo優(yōu)化關(guān)鍵詞
一.DML(Data Manipulation Language)
用來對(duì)數(shù)據(jù)庫中表的數(shù)據(jù)記錄進(jìn)行更新
關(guān)鍵字:增刪改
插入insert
刪除delete
更新update
1.數(shù)據(jù)插入
insert into 表(列名1,列名2,列名3……)values(值1,值2,值3……)
注意:需要一一對(duì)應(yīng)
insert into 表 values(值1,值2,值3……)
//向表中所有列插入值
2.數(shù)據(jù)修改
update 表名 set 字段名=值,字段名=值……;
update 表名 set 字段名=值,字段名=值……where 條件;
將所有學(xué)生的地址修改為重慶
update student set address='重慶';
將id為1004的學(xué)生的地址修改為北京
update student set address='北京' where id=1004;
3.數(shù)據(jù)刪除
delete from 表名 where 條件;
truncate table 表名;/truncate 表名;
注意:delete與truncate原理不同,delete只刪除內(nèi)容,而truncate類似于drop table ,可以理解為將整個(gè)表刪除,然后再創(chuàng)建該表;
刪除sid為1004的學(xué)生數(shù)據(jù)
delete from student where id=1004;
刪除表中所有數(shù)據(jù)
delete from student;
清空表數(shù)據(jù)
truncate table student;
truncate student;
二.總結(jié)?
use mydb1;
CREATE TABLE IF NOT EXISTS EMPLOEE(
id int,
name varchar(20),
sex varchar(10),
salary double
);
#數(shù)據(jù)插入
insert into EMPLOEE values(1,'張三','男',2000),(2,'李四','男',3000),(3,'王五','女',4000);
#數(shù)據(jù)修改
update EMPLOEE set salary=6000;
update EMPLOEE set salary=3000 where name='張三';
update EMPLOEE set salary=salary+1000 where name='王五';
#數(shù)據(jù)刪除
#delete from EMPLOEE;