工作中常用的sql语句以及知识整理
2016-08-26 15:47
447 查看
一、常用的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 '%查找的内容%'
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 '%查找的内容%'
相关文章推荐
- 关于过去工作的一些总结:常用sql语句以及数据库查询优化
- SQL条件循环语句以及异常知识整理
- SQL_Server 常用语句以及语法整理
- discuz6.0常用sql语句整理
- 工作中常用的SQL语句,随用随加
- 应聘中常用的SQL语句(数据库知识必杀)一共50个
- 收藏的SQL知识以及SQL语句简单实践通俗易懂
- 我自己整理的一些常用SQL语句,希望对大家有用啊
- SQL常用语句整理
- 常用SQL语句自整理(不定时补全)
- oralce 基础知识 ,oralce 常用简单sql语句,oracle 新手必看之一
- 面试、笔试中常用的SQL语句(数据库知识必杀)一共50个!!!
- Transact SQL 常用语句以及函数
- 应聘中常用的SQL语句(数据库知识必杀)一共50个
- SQL 常用语句以及函数(个人收藏)
- 个人整理摘录的SQL2005新增几种常用的T-SQL语句
- 『管理调优』Oracle维护常用SQL语句整理四
- 『管理调优』Oracle维护常用SQL语句整理三
- 一道练习题引申出来的知识点(五) 常用的sql语句 以及相关概念
- sql常用语句集合(工作总结)