zoukankan      html  css  js  c++  java
  • 工作中常用的sql语句以及知识整理

    一、常用的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 '%查找的内容%'

  • 相关阅读:
    android 5.1 WIFI图标上的感叹号及其解决办法
    Recovery和Charger模式下屏幕旋转180度
    Android屏幕旋转总结
    Spring MVC 数据校验@Valid
    Spring注解装配
    Spring简单的REST例子
    Spring怎么引入多个xml配置文件
    spring使用c3p0报错
    Spring+JTA+Atomikos+MyBatis分布式事务管理
    (2-3)Eureka详解
  • 原文地址:https://www.cnblogs.com/jiangxiaoyaoblog/p/5810646.html
Copyright © 2011-2022 走看看