1、Insert into
1.1、向所有行插入数据
Insert into UserInfo values('0001','Tom','M');
Insert into UserInfo values('0002','Jhon','M');
Insert into UserInfo values('0004','Tom','M');
1.2、向指定列插入数据
Insert into UserInfo(UserInfoID,NICKNAME) VALUES('0003','Jobs');
INSERT INTO messagerecord(comeuser,touser,messagecontent) VALUES('小伙伴','阿宝哥','World');
Insert into MessageREcord(comeuser,touser,messagecontent) values('小伙伴001','阿宝哥','World');
select * From USERINFO;
select * from messagerecord;
2、Update
Where字句决定着哪些行将会被更新。
2.1、更新所有列
--Sample1:更新所有列
Update UserInfo
Set Sex = 'W';
2.2、更新指定列
--Sample2:
Update UserInfo
Set Sex = 'M'
--Where UserInfoID = '0003';
Where NICKNAME Like 'J%';
select * From USERINFO;
UPDATE messagerecord
SET messagecontent = 'Hello World!';
SELECT * FROM messagerecord;
UPDATE messagerecord
SET messagecontent = 'Hello World!',
touser = '陈'
Where comeuser = '小伙伴001';
3、Delete
Where字句决定着哪些行将会被删除。
3.1、删除指定行
Delete UserInfo
--Where UserInfoID = '0003';
Where NickName = 'Jhon';
3.2、删除所有行
Delete UserInfo;
select * From USERINFO;
DELETE messagerecord
where comeuser != '小伙伴001';
SELECT * FROM messagerecord;