1、插入多条
insert into cust_info(cust_name,
cust_tele,
cust_address)
values(
'Pep E',
'15988888888',
'shanghai'
),
values(
'M.Martian'
'17799999999',
'beijing'
);
2、insert select语句
insert into cust_info(cust_name,
cust_tele,
cust_address)
select cust_name1, //对应列的名称可以不同,insert并不关心名称,只是对应项插入
cust_tele1,
cust_address1
from cust_info_1
where cust_id1<=100;
3、更新多个数据
update cust_info //使用update ignore cust_info可以忽略更新时的错误
set cust_name='zhangsan',
cust_address='beijing',
cust_qq=NULL //允许更新为NULL
where cust_id=1005;
4、删除记录
delete from table_name
where col_prim='...';
5、删除表中的每一条记录,使用truncate table语句比不带where 的delete语句要更快
6、视图的理解:视图中没有数据,视图实际上 是方便查询的,而不是用于更新、删除(某些情况下也可以,看能不能确定基表中需要操作的数据)。可以把从视图中的检索,看做是对定义视图的时候的select结果集的检索。
示例1
示例2:重新格式化检索出来的数据
扫描二维码关注公众号,回复:
2536008 查看本文章
示例3:视图过滤掉不需要的数据
示例4:视图与计算字段