当前位置: 首页 > news >正文

HeidiSQL中一些简单mysql语句的含义(一)

一、创建数据库

#创建一个数据库,这个是数据库的名字叫java62

create database java62;

#删除数据库java62

drop database java62;

#查看当前mysql里的所有数据库

show databases;

#创建student表,varchar括号里的是字符串的长度

create table student(no int ,name varchar(10),age int);

#查看当前数据库里有哪些表

show tables;

#删除student表

drop table student;

二、增删改查

#向student 表中插入数据

insert into student (no,name,age) values (1001,'张三',20);

#插入两条数据

insert into student (no,name,age) values(1002,'李四',21),(1003,'王五',22);

注:如果不想某个字段重复,可以给它设置主键

#当我要给表中每个字段都写入数据的时候,可以不写字段名

#如果给部分字段赋值,则必须写字段名

insert into student values (1004,'测试',20);

#删除表中所有数据

delete from student;

#在student表中删除no=1004的数据

delete from student where no=1004;

#把所有数据进行修改

update student set age=23 ;

#把 no=1003的一条数据中age改为23

update student set age=23 where no=1003;

#年龄加1

update student set age=age+1 where no=1003;

#把no=1003中name改为测试2,age改为20

update student set name='测试2',age=20 where no=1003;

#查询表中所有数据

select * from student;

#查询name的所有数据

select name from student;

#查询name和age

select name,.age from student;

#查询张三的所有数据

select * from student where name='张三';

#查询age>20的数据

select * from student where age>20;

#查询 name='张三' 或者age=21的数据

select * from student where name='张三' or age=21;

#查询 name='张三' 并且age=21的数据

select * from student where name='张三' and age=21;


http://www.mrgr.cn/news/8907.html

相关文章:

  • 如何评估Redis的性能
  • 面向对象编程:深入PHP的封装、继承和多态性!
  • tomcat实战演练
  • 《机器学习》—— OpenCV 对图片的各种操作
  • LCD模组驱动开发
  • ES详细使用!Elasticsearch实现索引操作,增删改查,批处理
  • 基于element-ui 日期选择器el-date-picker, 即对日期做区间限制
  • 设计模式-访问器模式
  • TypeScript 面试题汇总
  • 掌握CSS3的transform-origin:让你的网页动画更生动
  • Lumos学习王佩丰Excel第十三讲:邮件合并
  • 基于vue框架的比赛门票出售的系统12lh6(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
  • [数据集][目标检测]建筑工地楼层空洞检测数据集VOC+YOLO格式2588张1类别
  • 解密巴黎奥运会中的阿里云AI技术
  • 爬取央视热榜并存储到MongoDB
  • vue3 安装element-plus进行一些简单的测试
  • 实现el-table 两列多选框且不可同时勾选,可单选,可多选
  • java中的Collections
  • docker的安装+docker镜像的基本操作
  • Flutter-->Widget上屏之路