mlsql 基本操作

数据库的操作:

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 (范围查询)

 

转载于:https://www.cnblogs.com/huanghaobing/p/9996381.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值