• mysql 基本操作


    数据库的操作:

    1.创建

    create databases python_test_01(库名,自定义)chaeset = utf8;

    2.删除

    drop database python_test_01;

    3.选择使用数据库

    use python_test_01;

    mysql支持多种类型,大致分为三类:数值,日期/时间和字符串(字符)类型

    创建班级表

    use python_test_01;

    create table classes(

               id INT unsigned primary key auto_increment not null,

    name varchar(30) not null default'   '

    )

    修改表名

    alter table 表名 rename to 新表名;

    删除表

    drop table 表名; 

    创建学生表

    create table student(

           id INT unsigned primary key auto_increment  not null,

           name varchar(30) not null default'  '  commment'姓名‘

            age tinyint default 0 commment '年龄‘

             height decimal(3,2) comment '身高‘

             gender enum('男',' 女')default ' 男‘ comment ‘性别’

             cls_id int unsigned default 0 commment '所属班级id'

              is_delete bit default 0 comment '是否删除'

              add_time datetime comment '添加时间'

             )

    use 数据库名;show tables;   查看表结构  desc 表名;

    插入数据

    insert into 表名 values()

    select id,name from student;     查询所有记录

    select id from student;   查询指定字段

    select id as code from student;  使用as起别名长的字段用到

    where:

    1.比较运算

    2.逻辑运算

    3.模糊查询

    4.范围查询

    5.空判断

    格式:select 字段 1,字段2 from 表名 where 条件

    between ...... and (范围查询)

  • 相关阅读:
    MySQL主主同步方案
    Mysql增量备份与恢复
    配置合适的存储引擎
    基于Amoeba读写分离
    部署myaql主从异步复制
    MySQL完全备份操作
    echo 命令详解
    ELK 基本部署
    zabbix 简介
    基于 Git Tag 发布及回滚代码
  • 原文地址:https://www.cnblogs.com/huanghaobing/p/9996381.html
Copyright © 2020-2023  润新知