一、常用的sql语句
1、建表语句
create table tabname(colname1 type1 [not null][primary key], colname2 type2,...)
根据已有的表创建新表
A:create table tab_new like tab_old
B:create table tab_new asselect colname1,colname2... from tab_old definition only
2、删除表
drop table tabname
3、增加一列
alter table tabname add column type DEFAULT '' COMMENT '***'
4、常用的基本的sql
选择:select * from table1 where 范围
插入:insert into table1(field1,field2) values (value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1=value1 where 范围
查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料!
排序:select * from table1 orderby field1,field2 [desc]
总数:select countas totalcount from table1
求和:select sum(field1) as sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(field1) as minvalue from table1
二、提升
1、replace
select replace(object,'old_text','new_text')
update table set name=replace(name,'aa',bb') where name like '%查找的内容%'