找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
<:select *from wuhandcs where time= ,=\&quot;2022-07-01\&quot; and time mysql 当中 表数据结构的操作方法:
    alter table 操作表结构
    修改表名称:
   rename :更改数据库名称
  alter table+文件名 rename 新文件名

  修改字段名称 : change
  alter table wuhan change  id s_id int(4)
添加自增长:alter table wuhan change id id int(4) not null;

alter table wuhandcs change s_id s_id int(4)auto_increment;

修改字节储存大小:
alter table wuhandcs change phone phone bigint(20);

add添加字段
alter table wuhandcs add age int(4);
添加多个字段:
alter table wuhandcs add (age1 int(4),age2  int(4));

add 添加值的同时也可以给约束
alter table wuhandcs add sex char(4)not null;

modfy 调整顺序:
first:将指定的字段放第一位 : alter table wuhandcs modify name char(20) first;
after:将字段放在指定的字段后一位:alter table wuhandcs modify name char(20) after class;
add 也可以结合 first after 调整字段位置,需要新增字段进行调整。

dorp 删除;  
     删除表字段:
alter table wuhandcs drop sjx;
删除多个字段:
alter table wuhandcs drop age,drop age1,drop age2;

删除主键:(前提是要删除自增长)
alter table wuhandcs drop primary key;
添加主键跟自增长:
alter table wuhandcs change s_id s_id int(4)primary key auto_increment;

alter table 针对表结构进行操作:
cerate drop alter table 都是属于表结构操作语法

表数据操作语法:
insert into(插入)  select查询)    update(修改) delete(删除)
insert into wuhandcs(字段)values(值)
给所有字段添加值:
insert into wuhandcs values(7,"lpw",13800000000,1997.22,"2022-07-01","0");
给所有字段添加多个值:
insert into wuhandcs values(7,"lpw",13800000000,1997.22,"2022-07-01","0"),(8,"lpw",13800000000,1997.22,"2022-07-01","0");

匹配所有内容:
1.查询单个字段的信息:select phone,lass from wuhandcs
  查询多个字段的信息:select phone,name class from wuhandcs;
2.select 语句条件查询 需要用到where 条件语句
=条件:select *from wuhandcs where phone =18771639751;
!=:select *from wuhandcs where name != "sjx"; 排除“sjx”条件查询
><:select *from wuhandcs where time<"2022-07-02"; 日期大于小于查询 (>= ,<=) 大于等于 ,小于等于

逻辑运算符号
and 且的关系
select *from wuhandcs where id=4 or phone =1380000000000;
查询 null  :is null;  is not null;
in :select *from wuhandcs where id in (1,2,3,4,5,6);
not  in:select *from wuhandcs where id not in (1,2,3,4,5,6);
select *from wuhandcs where time >="2022-07-01" and time <="2022-07-03"; 按时间顺序查询
select *from wuhandcs where time between "2022-07-01"and "2022-07-03";按时间顺序查询
select *from wuhandcs limit 2,3;(这里的2指的是从第二行开始,3指的取值范围)。

like:匹配查询
select *from wuhandcs where phone like "%8";

order by :(排序)
select *from wuhandcs order by id desc; 降序排列
select *from wuhandcs order by id asc;   升序排列

聚合函数
max :最大  select max(class) from wuhandcs;
  min:最小   select min(class) from wuhandcs;
  avg :平均值:select avg (class) from wuhandcs;
  sum   求和    select sum (class) from wuhandcs;
count:统计所有行 select  count (class) from wuhandcs;
distinct 去重 去除重复的数据

分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册