mybatis与mybatisplus

mybatis

基本使用

整合springboot

1.添加依赖
2.添加配置
spring:# 数据源相关配置datasource:username: rootpassword: 123456driver-class-name: com.mysql.cj.jdbc.Driver#时区必须配置否则报错,注意数据库名切换为自己的数据库名称url:  jdbc:mysql://127.0.0.1/itheima?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
#mybatis 相关配置
mybatis:# 指定接口映射文件的位置mapper-locations: classpath:mapper/*.xml# 为POJO类指定别名 指定后使用时不再需要指定包名type-aliases-package: com.itheima.integration.pojo
# 开启debug日志
logging:level:com.itheima.springbootinit4: debug
3.指定DAO接口所在的包

@Mapper、@MapperScan详解

@SpringBootApplication
@MapperScan("com.winter.dao")
public class SpringbootMybatisDemoApplication {public static void main(String[] args) {SpringApplication.run(SpringbootMybatisDemoApplication.class, args);}
}

模糊查询

在这里插入图片描述

获取自增主键

插入数据后获取自增主键的方案有两种,分别是使用<selectKey>useGeneratedKeys属性
在这里插入图片描述

在这里插入图片描述
扩展 如果id为字符串类型,主键由uuid生成
在这里插入图片描述

ognl 表达式

#{} 【推荐】: 占位符, 相当于PreparedStatement对象, 会自动转换类型pojo对象 		 #{对象中的属性名} -- 获取pojo中的属性基本数据类型 	  #{参数名}	-- 获取基本类型数据,参数名通过@Param("xxxx")指定
${}	: 拼接符, 相当于字符串直接拼接, 不会自动转换类型,需要手动拼接类型pojo对象 		${对象中的属性名}	-- 获取pojo中的属性基本数据类型   ${参数名}  -- 获取基本类型数据,参数名通过@Param("xxxx")指定
 User selectById( @Param("id") Integer id);
<!--属性id              对应方法名,唯一parameterType   参数的类型,可以省略resultType      返回值类型
-->
<select id="selectById" parameterType="java.lang.Integer" resultType="com.itheima.entity.User">select * from t_user where id = #{id}
</select>
<!--
获取mapper传入参数
1.简单类型:四类八种, String  获取:使用`#{}`直接获取参数,名称可以任意写(有注解时与注解保一致)
2.实体对象参数(POJO类)
获取:使用`#{}`直接获取对象的属性(有注解时,注解内容 点 属性)
-->

标签

resultMap 标签

    <!--定义映射id:映射的名字type:实体类--><resultMap id="userResultMap" type="User"><!--定义字段映射,id和result标签分别表示主键字段映射和非主键字段映射property    实体类中的属性名column      SQL返回结果的列名如果property和cloumn的值相同,可以省略--><id property="id" column="id"/><result property="userName" column="user_name"/><result property="birthday" column="birthday"/><result property="sex" column="sex"/><result property="homeAddress" column="home_address"/></resultMap>

在这里插入图片描述

where 与 if 标签

    <!--where:1. where标签就相当于SQL语句中where关键字2. 去掉多余的and、or关键字if:判断条件是否为真,如果为真则将if中字符串拼接到SQL语句中-->    <select id="selectByUserNameAndSex" resultMap="userResultMap">select * from t_user<where><if test="userName!=null and userName!=''">user_name=#{userName}</if><if test="sex!=null and sex!=''">and  sex=#{sex}</if></where></select>

set 标签

    <!--set1.一般与if标签配合使用2.set用在update语句中,相当于set关键字3.会自动去掉能多余的逗号--><update id="updateByIdSelective">update t_user<set><if test="userName!=null">user_name = #{userName},</if><if test="birthday!=null">birthday = #{birthday},</if><if test="sex!=null">sex = #{sex},</if><if test="homeAddress!=null">home_address = #{homeAddress},</if></set>where id=#{id}</update>

foreach 标签

    <insert id="insertRecords">insert into t_user values<foreach collection="users" item="user"  separator=",">(#{user.id}, #{user.userName}, #{user.birthday}, #{user.sex}, #{user.homeAddress})</foreach></insert><delete id="deleteByIdS">delete from t_user where id in<!--open     遍历开始前添加的符号close    遍历完成后添加的符号--><foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach></delete>

在这里插入图片描述

sql/include标签

  1. sql标签:定义一段可以重用的SQL语句
  2. include标签:refid 关联sql标签的id
    <!--定义可重用的代码块--><sql id="conditionSql"><if test="condition!=null and condition!=''">where user_name like concat('%',#{condition},'%')or home_address like concat('%',#{condition},'%')</if></sql><!--根据条件查询--><select id="selectByConditon" resultMap="userResultMap">select * from t_user<!--引用代码块--><include refid="conditionSql"/></select><!--根据条件统计--><select id="countByConditon" resultType="int">select count(1) from t_user<!--引用代码块--><include refid="conditionSql"/></select>

结果集复杂映射

当SQL查询的结果集复杂,不能(或不方便)使用一个类结构来接收这些数据,我们就称这种映射是复杂映射。复杂映射一般分为两种:一对一、一对多。

一对一映射通过<assosication>标签实现;一对多映射通过<collection>标签实现。

一对一映射

在这里插入图片描述
在这里插入图片描述

一对多

    <!--一对多映射1. collection标签,用于表示数据查询中的1对多映射2. 此时,resultMap和collection都需要指定所有字段的映射,不能省略(同association)3. SQL查询的结果集中不能有重复的字段,如果有重复字段,则映射过程中只有第一个字段可以取到正确的值,所以需要给名称重复的字段使用别名。(同association)--><resultMap id="userAndOrderResultMap" type="User"><id property="id" column="id"/><result property="username" column="username"/><result property="birthday" column="birthday"/><result property="sex" column="sex"/><result property="address" column="address"/><!--collection  映射成一个集合porperty 类属的属性名ofType  集合内元素的类型--><collection property="orders" ofType="Order" ><id property="id" column="o_id"/><result property="userId" column="o_user_id"/><result property="goods" column="o_goods"/><result property="createTime" column="o_create_time"/><result property="note" column="o_note"/></collection></resultMap><select id="selectUserAndOrderById" resultMap="userAndOrderResultMap">SELECT tu.*,tor.id o_id,tor.user_id o_user_id,tor.goods o_goods,tor.create_time o_create_time,tor.note o_noteFROM t_user tu join t_order tor on tu.id=tor.user_idwhere tu.id=#{id}</select>

在这里插入图片描述

级联(嵌套)查询

在这里插入图片描述

public interface UserMapper{/*** 查询所有用户基本信息、拓展细信、订单** @return*/List<User> selectAllUserAndInfoAndOrder();
}
    <!--用户详细信映射--><resultMap id="userDetailResultMap" type="User"><id property="id" column="id"/><result property="username" column="username"/><result property="birthday" column="birthday"/><result property="sex" column="sex"/><result property="address" column="address"/><!--association和collection都可以通过column属性和select属性配合完成级联查询操作select  子查询,一个select标签的idcolumn  指定参数传递--><association property="userInfo" column="id" select="selectUserInfoByUserId"/><collection property="orders"   column="id"  select="selectOrderByUserId"/></resultMap><!--用户拓展信息映射--><resultMap id="userInfoResultMap" type="UserInfo"><result property="userId" column="user_id"/></resultMap><!--订单信息映射--><resultMap id="orderResultMap" type="Order"><result property="userId" column="user_id"/><result property="createTime" column="create_time"/></resultMap><!--查询用户信息--><select id="selectAllUserAndInfoAndOrder" resultMap="userDetailResultMap">select * from t_user</select><!--查询用户拓展信--><select id="selectUserInfoByUserId" resultMap="userInfoResultMap">select * from t_user_info where user_id=#{userId}</select><!--查询订单信--><select id="selectOrderByUserId" resultMap="orderResultMap">select * from t_order where user_id=#{userId}</select>

在这里插入图片描述

自动映射

当自动映射查询结果时,MyBatis 会获取结果(sql查询结果集)中返回的列名并在 Java 类中查找相同名字的属性(忽略大小写)。 这意味着如果发现了 ID 列和 id 属性,MyBatis 会将列 ID 的值赋给 id 属性。

通常数据库列使用大写字母组成的单词命名,单词间用下划线分隔;而 Java 属性一般遵循驼峰命名法约定。
在这里插入图片描述

注解开发

增删改查注解

@Select(“查询语句”)查询;
@Update(“更新语句”)更新;
@Delete(“删除语句”)删除;
@Insert(“插入语句”)插入;
@SelectKey()

public interface UserMapper {@Select(value = "select * from t_user where username like concat('%',#{username},'%')")List<User> selectByLike(String username);/*** 分页查询* @param startIndex* @param pageSize* @return*/@Select(value = "select * from t_user limit #{param1}, #{param2}")List<User> selectByPage1(Integer startIndex, Integer pageSize);/*** 分页查询* @param startIndex* @param pageSize* @return*/@Select(value = "select * from t_user limit #{startIndex}, #{pageSize}")List<User> selectByPage2(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);/*** 查询所有* @return*/@Select(value = "select * from t_user")List<User> selectAll();/*** 通过id查询用户基础信息*/@Select(value="select * from t_user where id = #{id}")User selectById(@Param("id") Integer id);/*** 更新用户信息基础信息* @param user* @return*/@Update(value=" update t_user set username=#{username}, birthday=#{birthday}, sex=#{sex}, address=#{address} where id=#{id}")int update(User user);/*** 更新用户信息基础信息* @param id* @return*/@Delete(value=" delete from  t_user where id=#{id}")int deleteById(@Param("id") Integer id);/*** 插入* @param user* @return*/@Insert("insert into t_user(username,birthday,sex,address) values (#{username},#{birthday},#{sex},#{address})")@SelectKey(resultType = Integer.class,keyProperty ="id",before = false,statement = "select LAST_INSERT_ID()")int insert(User user);
}

在这里插入图片描述

结果映射

@Results:
@Result
在这里插入图片描述

@Results:
含义:封装映射关系的父注解。
属性
value: 定义了Result 数组
@Result
含义:封装映射关系的子注解。
属性
id: 是否是主键
column:查询出的表中字段名称
property 属性:实体对象中的属性名称
javaType属性:被包含对象的数据类型

一对一级联查询

@One

@Results(value = {@Result(id = true, column = "id", property = "id"),@Result(column = "user_name", property = "userName"),@Result(column = "sex", property = "sex"),@Result(column = "birthday", property = "birthday"),@Result(column = "home_address", property = "homeAddress"),@Result(property = "userInfo",column = "id",one = @One(select = "com.itheima.dao.UserInfoMapper.selectUserInfoByUserId"))   
})
@Select(value="select * from t_user where id = #{id}")
User selectById(@Param("id") Integer id);
public interface UserInfoMapper {@Select("select * from t_user_info where user_id = #{user_id}")UserInfo selectUserInfoByUserId(Integer userId);
}

@Results : 映射结果集
@Result: 映射某一列
@One: 一对一映射

一对多级联查询

@Many: 一对多映射

@Results(value = {@Result(id = true, column = "id", property = "id"),@Result(column = "user_name", property = "userName"),@Result(column = "sex", property = "sex"),@Result(column = "birthday", property = "birthday"),@Result(column = "home_address", property = "homeAddress"),@Result(property = "userInfo",column = "id",one = @One(select = "com.itheima.dao.UserInfoMapper.selectUserInfoByUserId")),@Result(property = "orders",column = "id",many = @Many(select = "com.itheima.dao.OrderMapper.selectOrderListByUserId"))
})
@Select(value="select * from t_user where id = #{id}")
User selectById(@Param("id") Integer id);
public interface UserInfoMapper {@Select("select * from t_user_info where user_id = #{user_id}")UserInfo selectUserInfoByUserId(Integer userId);
}

@Results : 映射结果集
@Result: 映射某一列
@Many: 一对多映射

原理

二级缓存

mybatisPlus

国内研发,在 MyBatis 的基础上只做增强不做改变
官网

依赖

    <!--SpringBoot--><dependency><groupId>com.baomidou</groupId><!--下面坐标根据自己使用的SpringBoot版本二选一--><!--SpringBoot2使用此版本--><artifactId>mybatis-plus-boot-starter</artifactId><!--3.5.4开始,支持SpringBoot3使用此版本--><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>最新版本</version></dependency>

配置

配置文件

mybatis-plus:mapper-locations: classpath:net/cnki/editor/expense/dao/impl/*.xml#类型:String[]#默认值:["classpath*:/mapper/**/*.xml"] #MyBatis Mapper 所对应的 XML 文件位置,如果您在 Mapper 中有自定义方法(XML 中有自定义实现),需要进行该配置,告诉 Mapper 所对应的 XML 文件位置,Maven 多模块项目的扫描路径需以 classpath*: 开头 (即加载多个 jar 包下的 XML 文件)type-aliases-package: net.cnki.editor.expense.dos#类型:String#默认值:null#MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名,注册后在 Mapper 对应的 XML 文件中可以直接使用类名,而不用使用全限定的类名(即 XML 中调用的时候不用包含包名)configuration.map-underscore-to-camel-case: true#类型:boolean#默认值:true#是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射。global-config.db-config.id-type: assign_id# 类型:com.baomidou.mybatisplus.annotation.IdType#默认值:ASSIGN_ID#全局默认主键类型

注解

官网注解

@MapperScan

在 Spring Boot 启动类中添加 @MapperScan 注解,扫描 Mapper 文件夹:
每天一个注解之@MapperScan

@SpringBootApplication
@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}}

@TableName

描述:表名注解,标识实体类对应的表
使用位置:实体类

@TableId

描述:主键注解
使用位置:实体类主键字段

@TableField(opens new window)

描述:字段注解(非主键)

使用

springboot整合

1.添加依赖
2.添加配置文件
3.添加启动类扫描

@Mapper、@MapperScan详解

@SpringBootApplication
@MapperScan("com.winter.dao")
public class SpringbootMybatisDemoApplication {public static void main(String[] args) {SpringApplication.run(SpringbootMybatisDemoApplication.class, args);}
}
4.添加实体类
@TableName("tb_user")
@Data
public class User {//设置id生成策略:AUTO 数据库自增@TableId(type = IdType.AUTO)private Long id;//@TableField("user_name")private String userName;private String password;private String name;private Integer age;private String email;//不希望该值存入数据库// @TableField(exist = false)// private String info;}
5.创建mapper(可通过插件生成)
/*** 使用mp定义Mapper,需要让Mapper接口继承 BaseMapper接口。*/public interface UserMapper extends BaseMapper<User> {
}
6.创建service

public interface _UserService extends IService<User> {
}
@Service
public class _UserServiceImpl extends ServiceImpl<UserMapper, User> implements _UserService {}
7.分页查询,添加分页拦截器
@Configuration
public class PageConfig {/*** 3.4.0之前的版本用这个* @return*//* @Beanpublic PaginationInterceptor paginationInterceptor(){return  new PaginationInterceptor();}*//*** 3.4.0之后提供的拦截器的配置方式* @return*/@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());return mybatisPlusInterceptor;}
}
/*** 分页查询:*  1. 当前页码:currentPage*  2. 每页显示条数:size**  注意:使用mp的分页要设置一个拦截器!!!*/@Testpublic void testSelectPage() {int current = 1;//当前页码int size = 2;//每页显示条数IPage<User> page = new Page(current,size);userMapper.selectPage(page,null);List<User> records = page.getRecords();//当前页的数据long pages = page.getPages();//总页数 2long total = page.getTotal();//总记录数 4System.out.println(records);System.out.println(pages);System.out.println(total);}
8.条件构造器
基础比较查询
Wrapper()包装器://条件构建器1.QueryWrapperLambdaQueryWrapper2.UpdateWrapperLambdaUpdateWrapper方法:
eq( ) :  等于 =
ne( ) :  不等于 <>
gt( ) :  大于 >
ge( ) :  大于等于  >=
lt( ) :  小于 <
le( ) :  小于等于 <=
between ( ) :  BETWEEN1 AND2 
notBetween ( ) :  NOT BETWEEN1 AND2 
in( ) :  in
notIn( ) :not in逻辑查询
or( ) :让紧接着下一个方法用or连接 模糊查询
like 查询关键字前后都加%
notLike
likeLeft
likeRight排序查询
orderBy
orderByAsc通过某个条件正排
orderByDesc反排select:指定需要查询的字段
@Testpublic void testWrapper2(){//1.创建查询条件构建器QueryWrapper<User> wrapper = new QueryWrapper<>();//2.设置条件wrapper.eq("user_name","lisi").or().lt("age",23).in("name","李四","王五");/*select * from tb_user where user_name = ? or age < ? and name in (?,?)*/List<User> users = userMapper.selectList(wrapper);System.out.println(users);}

LambdaQueryWrapper:消除代码中的硬编码

@Testpublic void testWrapper7(){LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();wrapper.eq(User::getUserName,"zhangsan");userMapper.selectOne(wrapper);}

LambdaQueryWrapper原理

代码生成工具,IDE插件

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/2061.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

论文略读:OpenGraph: Towards Open Graph Foundation Models

arxiv 2023 1 intro Graph大模型希望OpenGraph能够捕捉通用的拓扑结构模式&#xff0c;对测试数据进行Zero-shot预测 仅通过前向传播过程&#xff0c;就可以对测试图数据进行高效的特征提取和准确预测模型的训练过程在完全不同的图数据上进行&#xff0c;在训练阶段不接触测试…

【2024年5月备考新增】】软考极限冲刺 《项目质量管理1》

1 知识点 1.1 质量成本 一致性成本 项目花费资金规避失败 预防成本:(打造某种高质量产品) 培训文件过程设备完成时间评估成本:(评估成本) 测试破坏性试验损失检查非一致性成本 项目前后花费的资金(由于失败) 内部失败成本:(项目中发现的失败) 返工报废外部失败成本:…

windows安装nc命令的解决方案

大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作的方式对所学的…

(mac)Prometheus监控之Node_exporter(CPU、内存、磁盘、网络等)

完整步骤 1.启动 Prometheus 普罗米修斯 prometheus --config.file/usr/local/etc/prometheus.yml 浏览器访问 http://localhost:9090/targets 2.启动Node_exporter node_exporter 访问&#xff1a;http://localhost:9100 3.启动grafana brew services start grafana 访问…

力扣146. LRU 缓存

Problem: 146. LRU 缓存 文章目录 题目描述思路复杂度Code 题目描述 思路 主要说明大致思路&#xff0c;具体实现看代码。 1.为了实现题目中的O(1)时间复杂度的get与put方法&#xff0c;我们利用哈希表和双链表的结合&#xff0c;将key作为键&#xff0c;对应的链表的节点作为…

2024年前端技术发展趋势

&#x1f49d;&#x1f49d;&#x1f49d;欢迎莅临我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」…

如何用idm下载迅雷文件 idm怎么安装到浏览器 idm怎么设置中文

如果不是vip用户使用迅雷下载数据文件&#xff0c;其下载速度是很慢的&#xff0c;有的时候还会被限速&#xff0c;所以很多小伙们就开始使用idm下载迅雷文件&#xff0c;idm这款软件最大的优势就是下载速度快&#xff0c;还有就是具备网页捕获功能&#xff0c;能够下载网页上的…

ESD+显示模组

ESD测试是指对消费电子设备进行静电放电测试&#xff0c;通常用于检查设备是否具有防静电能力&#xff0c;以及在正常使用过程中是否容易受到静电干扰&#xff0c;通过进行ESD测试&#xff0c;可以评估设备的抗静电能力&#xff0c;并采取相应的措施以提高设备的耐静电性能。 E…

小米汽车超级工厂智能物流

导语 大家好&#xff0c;我是智能仓储物流技术研习社的社长&#xff0c;老K。专注分享智能仓储物流技术、智能制造等内容。 小米汽车超级工厂以其先进的智能物流系统&#xff0c;标志着汽车制造业在智能化和自动化方面迈出了重要一步。该工厂采用物联网(IoT)技术&#xff0c;实…

架构师系列-MYSQL调优(五)- JOIN、in及exists优化

JOIN算法原理 JOIN 是 MySQL 用来进行联表操作的&#xff0c;用来匹配两个表的数据&#xff0c;筛选并合并出符合我们要求的结果集。JOIN 操作有多种方式&#xff0c;取决于最终数据的合并效果。常用连接方式的有以下几种: 驱动表的定义 什么是驱动表 ? 多表关联查询时,第一…

Bert语言大模型基础

一、Bert整体模型架构 基础架构是transformer的encoder部分&#xff0c;bert使用多个encoder堆叠在一起。 主要分为三个部分&#xff1a;1、输入部分 2、注意力机制 3、前馈神经网络 bertbase使用12层encoder堆叠在一起&#xff0c;6个encoder堆叠在一起组成编码端&#xf…

Spring Boot中判断轨迹数据是否经过设置的打卡点,且在PGSQL中把点拼接成线,判断某个点是否在线上或在线的50米范围内

问题描述 轨迹数据判断是否经过打卡点&#xff0c;轨迹数据太多&#xff0c;循环判断的话非常消耗内存。解决办法只需要把所有轨迹数据点拼成了一条线&#xff0c;然后只需要循环打卡点即可&#xff0c;打卡点不多&#xff0c;一般不会超过100个&#xff0c;如果多的话&#x…

R可视化:桑基图展示数据层流动

介绍 以桑基图形式展示数据分布情况 加载R包 knitr::opts_chunk$set(message = FALSE, warning = FALSE) library(tidyverse) library(ggalluvial)# rm(list = ls()) options(stringsAsFactors = F) options(future.globals.maxSize = 10000 * 1024^2) 导入数据 metadata…

【计算机毕业设计】大学校园图书角管理系统——后附源码

&#x1f389;**欢迎来到我的技术世界&#xff01;**&#x1f389; &#x1f4d8; 博主小档案&#xff1a; 一名来自世界500强的资深程序媛&#xff0c;毕业于国内知名985高校。 &#x1f527; 技术专长&#xff1a; 在深度学习任务中展现出卓越的能力&#xff0c;包括但不限于…

【Flutter】One or more plugins require a higher Android SDK version.

问题描述 项目里多个组件需要更高版本的Android SDK One or more plugins require a higher Android SDK version.解决方案&#xff1a; 报错提示requires Android SDK version 34 按提示修改android项目app里build.gradle的compileSdkVersion 为34 android {compileSdkVe…

node.js-包

包的概念 包&#xff1a;将模块&#xff0c;代码&#xff0c;其他资料聚合成的一个文件夹 包分类&#xff1a; 1.项目包&#xff1a;主要用于编写项目和业务逻辑的文件夹 2.软件包&#xff1a;封装工具和方法供开发者使用&#xff08;一般使用npm管理&#xff09; 1&#…

mysql的DDL语言和DML语言

DDL语言&#xff1a; 操作数据库&#xff0c;表等&#xff08;创建&#xff0c;删除&#xff0c;修改&#xff09;&#xff1b; 操作数据库 1&#xff1a;查询 show databases 2:创建 创建数据库 create database 数据库名称 创建数据库&#xff0c;如果不存在就创建 crea…

MySQL—一条查询SQL语句的完整执行流程

MySQL—一条查询SQL语句的完整执行流程 表结构和数据如下&#xff1a; 我们分析的sql语句如下&#xff1a; select tb_id,tb_name,tb_address from tb_user where tb_id 66;大体来说&#xff0c;MySQL可以分为Server层和存储引擎层两部分: Server层 包括:连接器、查询缓存、…

使用Java实现动态心形图案

一、引言 在计算机图形学中&#xff0c;动态图案的生成和显示一直是一个令人兴奋的话题。心形图案作为情感表达的一种常见方式&#xff0c;在编程领域也颇受欢迎。本文将介绍如何使用Java编程语言实现动态心形图案&#xff0c;并附上相应的代码片段。 二、心形曲线的数学表达…

如何使用 ArcGIS Pro 快速为黑白地图配色

对于某些拍摄时间比较久远的地图&#xff0c;限于当时的技术水平只有黑白的地图&#xff0c;针对这种情况&#xff0c;我们可以通过现在的地图为该地图进行配色&#xff0c;这里为大家讲解一下操作方法&#xff0c;希望能对你有所帮助。 数据来源 教程所使用的数据是从水经微…