• 2019.10.9-数据库的命令


    数据库的命令:

    查看所有数据库:show databases;

    查看当前使用的数据库:select databases();

    切换数据库:use 数据库名;

    创建数据库:create database 数据库名 charser=utf8;

    删除数据库:drop databases 数据库名;

    数据库表的命令:

    查看所有表:show tables;

    创建表:create table 表名(id int auto_increment primary key not null,...);

    删除表:drop table 表名;

    修改表:alter table 表名 add|change|drop 列;

    数据库的命令crud:

    查询:select * from 表名;

    增加:insert into 表名 values(...);

    修改:update 表名 set 字段=值...

    删除:delete from 表名

    逻辑删除:本质就是修改

    逻辑运算符:

    and

    or

    not

    查询编号大于3的女生

    select * from students where id>3 and gender=0;

    查询编号小于4或没被删除的学生

    select * from students where id<4 or isdelete=0;

    模糊查询:like

    查询姓黄或叫靖的学生

    select * from students where name like '黄%' or name like ‘%靖’;

    范围查询:

    查询编号是1或3或8的学生

     select * from students where id in(1,3,8);

    查询学生是3至8的男生

    select * from students where id between 3 and 8 and gender=1;

    空判断、

    查询生日为空的学生

    select * from students where birthday is null;

    查询生日不为空的学生:select * from students where birthday is not null;

  • 相关阅读:
    通过Xshell连接CentOS虚拟机
    Linux学习笔记
    JAVA学习摘要
    4k 对齐,你准备好了吗?
    图片种子制作方法,利用图片上传附件
    利用京东服务免费打造属于自己的网站
    PE制作实录 —— 补充说明
    PE制作实录 —— 定义我的 PE 工具箱
    浏览器 — 各项基准测试
    Windows 8.1 归档 —— Step 3 软件的选择与安装
  • 原文地址:https://www.cnblogs.com/lishuide/p/11645063.html
Copyright © 2020-2023  润新知