zoukankan      html  css  js  c++  java
  • mysql 存储结构

    mysql存储结构:数据库->表->数据

    1)管理数据库

    增:create database sjk;

    删:drop database sjk;

    改:alter database sjk;

    查:show databases;

    2)管理表

    选择数据库:use sjk;

    增:create table 表(字段名1 字段名类型,字段名2 字段名类型);

    删:drop table 表;

    改:

    添加字段:alter table 表 add [行列] 字段名 字段类型;

    删除字段:alter table 表 drop [行列] 字段名 字段类型;

    修改字段类型:alter table 表 modify 字段名 新的字段类型;

    修改字段名称:alter table 表 change 旧的字段名 新的字段名 字段类型;

    修改表名称:alter table 表 rename 新表名

    3)管理数据

    增:insert into 表 (字段1,字段2......)values(值1,值2.....);

    删:delect from 表 where 条件

    改:update 表 set 字段1 = 值1 ,字段二 = 值二。。。。。。where条件

    查:

    所有字段:select *from 表;

    指定字段: select 字段1,字段2.。from 表;

    指定的别名: select 字段1 as 别名 form 表;

    合并列:select(字段1+字段2)from 表;

    去重 :select distinct字段 from 表

    给定条件:

    逻辑条件 :与(and)或(or)

    select*from  表  where 条件1 and/or 条件2

    比较条件:> < >= <= between and(在。。。。范围之内)

    select*from  表  where DD>=90

    判断条件

    判断:null is null /is not null

    判断空字符串 : =""

    模糊条件 :like

    % :替换当前任意的字符

     _:替换一个字符

    分页查询:

    limit起始行,查询行数

    起始行从0开始

    排序:order by 字段

    asc:正序,顺序

    desc:反序,倒序

    分组查询

    group by 字段

    分组后在筛选  having 条件

  • 相关阅读:
    sqlserver获取当前id的前一条数据和后一条数据
    C#实现测量程序运行时间及cpu使用时间
    类库dll引用不成功问题
    合并相同字段
    Android之来历
    XML and JSON 验证
    特殊符号
    git 使用
    格式化字符串:金额
    grunt + sass 使用记录
  • 原文地址:https://www.cnblogs.com/future-zmy/p/6040482.html
Copyright © 2011-2022 走看看