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

先网站开发后软件开发好站长统计app软件

先网站开发后软件开发好,站长统计app软件,口碑好的网站建设加工,网站权重是什么意思在项目中我们时常需要写SQL语句,或简单的使用注解直接开发,或使用XML进行动态SQL之类的相对困难的SQL,并在IDEA中操控我们的SQL,但网上大都图方便或者觉得太简单了,完全没一个涵盖两个方面的讲解。 单表: …

        在项目中我们时常需要写SQL语句,或简单的使用注解直接开发,或使用XML进行动态SQL之类的相对困难的SQL,并在IDEA中操控我们的SQL,但网上大都图方便或者觉得太简单了,完全没一个涵盖两个方面的讲解。

单表:

        DDL(表操作):

创表语句:

 约束:


常见的数据类型:

for example(例子):

create table address_book
(id            bigint auto_increment comment '主键'primary key,user_id       bigint                       not null comment '用户id',consignee     varchar(50)                  null comment '收货人',sex           varchar(2)                   null comment '性别',phone         varchar(11)                  not null comment '手机号',province_code varchar(12) charset utf8mb4  null comment '省级区划编号',province_name varchar(32) charset utf8mb4  null comment '省级名称',city_code     varchar(12) charset utf8mb4  null comment '市级区划编号',city_name     varchar(32) charset utf8mb4  null comment '市级名称',district_code varchar(12) charset utf8mb4  null comment '区级区划编号',district_name varchar(32) charset utf8mb4  null comment '区级名称',detail        varchar(200) charset utf8mb4 null comment '详细地址',label         varchar(100) charset utf8mb4 null comment '标签',is_default    tinyint(1) default 0         not null comment '默认 0 否 1是'
)comment '地址簿' collate = utf8mb3_bin;

          

查询语句:

修改语句:

                                                                               那么IDEA中是如何操作DDL语句的呢?                                                需要特别说的是,IDEA中想执行哪部分代码,就左键选中代码块变色,再点击绿色的执行按钮 

DML  :             

insert

@Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user)" +" VALUES" +" (#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
<insert id="insertBacth">insert into dish_flavor (dish_id, name, value)value<foreach collection="flavors" item="df" separator=",">(#{df.dishId},#{df.name},#{df.value})</foreach></insert>

Update

 <update id="update">
# yml中配置文件加的开启驼峰命名,只是java中Employee 类的 成员变量的驼峰命名 可以对应 数据库中的 参数名update employee<set><if test="name != null ">name = #{name},</if><if test="username != null ">username = #{username},</if><if test="password != null ">password = #{password},</if><if test="phone != null">phone =#{phone},</if><if test="sex != null ">sex = #{sex},</if><if test="idNumber != null ">id_Number = #{idNumber},</if><if test="status != null ">status = #{status},</if><if test="updateTime != null">update_Time = #{updateTime},</if><if test="updateUser != null ">update_User = #{updateUser},</if></set>where id = #{id}</update>

项目里一般都是动态SQL编辑数据,简单的update直接使用MP,根本没必要写

Delete

 @Delete("delete from dish_flavor where dish_id = #{dishid}")void deleteByDishId(Long dishid);
<delete id="deleteByIds">delete from dish_flavor where dish_id in<foreach collection="dishIds" item="dishId" open="(" close=")" separator=",">#{dishId}</foreach></delete>

DQL:

基本查询:

注意:代码中*是通配符,即查询所有

条件查询:

聚合函数:

分组查询:

排序查询:

分页查询:

但分页查询,不同于其他的DQL查询方式,它是项目较为重要的部分,我们一般会使用PageHelper这个插件,来简化我们的代码,以下是

分页查询的三点重要的步骤:

First:

       先pom.xml导入maven对应依赖

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId></dependency>

Second:

        在impl中写模板式代码

 public PageResult pageQuery( EmployeePageQueryDTO employeePageQueryDTO) {
//        select * from employee limit 0,10
//        开始分页查询PageHelper.startPage(employeePageQueryDTO.getPage(),employeePageQueryDTO.getPageSize());
//      这个是强制要求名字叫”page“,不能改,所以这需要创建对象Page<Employee> page = employeeMapper.pageQuery(employeePageQueryDTO);//        long total1 = employeeMapper.pageQuery(employeePageQueryDTO).getTotal();
//        List<Employee> records1 = employeeMapper.pageQuery(employeePageQueryDTO).getResult();long total = page.getTotal();List<Employee> records = page.getResult();return new PageResult(total,records);}

Third:

<select id="pageQuery" resultType="com.sky.entity.Employee">select * from employee<where><if test="name != null and name != ''">and name like concat('%',#{name},'%')</if></where>order by create_time desc</select>

多表:

分为逻辑外键和物理外键,见名知意,前者并没有物理层面的约束,后者则是有着物理层面的约束

以上是一份逻辑关联的SQL语句,这应该是企业最常用的方式

但,此方法也有缺点,若你没考虑周全,可能会误操作,所以物理外键可能更利于你保持数据完整性和同一性。

IDEA修改方法:

根据名称,进行添加,修改外键

多表查询:

先简单介绍一下笛卡尔积,两个集合一个集合数据量为2,另一个数据量为4,两个相乘则为8条,这就是笛卡尔积,

而我们肯定不需要冗余数据,所以需要消除冗余项

分类:

内连接就是取并集,外连接就是取AorB,子查询则是查询蓝色or橘色部分

内连接:

外连接:

 

子查询:

总结代码:
<select id="pageQuery" resultType="com.sky.vo.DishVO">select  d.* , c.name as category_name  from dish d left outer join category c on d.category_id = c.id<where><if test = "name!=null">and d.name like concat('%',#{name},'%')</if><if test = "categoryId != null">and d.category_id = #{categoryId}</if><if test = "status != null">and d.status = #{status}</if></where>order by d.create_time desc</select>

事务:

注意:
● 默认MySQL的事务是自动提交的,也就是说,当执行一条DML语句, MySQL会 立即隐式的提交事务。

索引:

当数据库的表中数据量很大时,DML等SQL语句会有很长的时耗。

索引(index)是帮助数据库高效获取数据的数据结构


..

语法:


文章转载自:
http://dinncostonker.ssfq.cn
http://dinncoeditorial.ssfq.cn
http://dinncocolluvial.ssfq.cn
http://dinncooakland.ssfq.cn
http://dinncoamperehour.ssfq.cn
http://dinncomethedrine.ssfq.cn
http://dinncoheptahydrated.ssfq.cn
http://dinncolacomb.ssfq.cn
http://dinncoexiguity.ssfq.cn
http://dinncowhalelike.ssfq.cn
http://dinncocardia.ssfq.cn
http://dinncoreexplore.ssfq.cn
http://dinncocompulsion.ssfq.cn
http://dinncofinally.ssfq.cn
http://dinncomeaningless.ssfq.cn
http://dinncotendance.ssfq.cn
http://dinncounfriendly.ssfq.cn
http://dinncoanc.ssfq.cn
http://dinncooverturn.ssfq.cn
http://dinncoripstop.ssfq.cn
http://dinncostipel.ssfq.cn
http://dinncosuperalloy.ssfq.cn
http://dinncocorrodent.ssfq.cn
http://dinncousrc.ssfq.cn
http://dinncosuperempirical.ssfq.cn
http://dinncomotorway.ssfq.cn
http://dinncoconcertina.ssfq.cn
http://dinncovoicespond.ssfq.cn
http://dinncogastrulate.ssfq.cn
http://dinncokolkhoznik.ssfq.cn
http://dinncoantibiotics.ssfq.cn
http://dinncolazaretto.ssfq.cn
http://dinncomacrophyllous.ssfq.cn
http://dinncovenetian.ssfq.cn
http://dinncounderway.ssfq.cn
http://dinncoisoelectronic.ssfq.cn
http://dinncopetrological.ssfq.cn
http://dinncohooray.ssfq.cn
http://dinnconephelometry.ssfq.cn
http://dinncototemism.ssfq.cn
http://dinnconecrology.ssfq.cn
http://dinncobaseset.ssfq.cn
http://dinncotriumvirate.ssfq.cn
http://dinncocounterexample.ssfq.cn
http://dinncokarsey.ssfq.cn
http://dinncodynamist.ssfq.cn
http://dinncoflunkey.ssfq.cn
http://dinncoseptillion.ssfq.cn
http://dinncodaishiki.ssfq.cn
http://dinncobrushwood.ssfq.cn
http://dinncoproduct.ssfq.cn
http://dinncohesper.ssfq.cn
http://dinncodacker.ssfq.cn
http://dinncotilda.ssfq.cn
http://dinncowoollenize.ssfq.cn
http://dinncoshindig.ssfq.cn
http://dinncoeffluence.ssfq.cn
http://dinncoantique.ssfq.cn
http://dinnconecklace.ssfq.cn
http://dinncooverdry.ssfq.cn
http://dinncoweismannism.ssfq.cn
http://dinncojig.ssfq.cn
http://dinnconictation.ssfq.cn
http://dinncocessionary.ssfq.cn
http://dinncofrcs.ssfq.cn
http://dinncocostean.ssfq.cn
http://dinncoweathercoat.ssfq.cn
http://dinncosolicitorship.ssfq.cn
http://dinnconationality.ssfq.cn
http://dinncopassivism.ssfq.cn
http://dinncoillocutionary.ssfq.cn
http://dinncomerca.ssfq.cn
http://dinncosquirrelly.ssfq.cn
http://dinncocomplain.ssfq.cn
http://dinncobarefooted.ssfq.cn
http://dinnconapiform.ssfq.cn
http://dinncoportraitist.ssfq.cn
http://dinncoantipyretic.ssfq.cn
http://dinncolsv.ssfq.cn
http://dinncoheist.ssfq.cn
http://dinncounwrung.ssfq.cn
http://dinncopresbyterianism.ssfq.cn
http://dinncogarnetberry.ssfq.cn
http://dinncoepigenic.ssfq.cn
http://dinncocentrist.ssfq.cn
http://dinncoironing.ssfq.cn
http://dinncozing.ssfq.cn
http://dinncosab.ssfq.cn
http://dinncotamburlaine.ssfq.cn
http://dinncoinsectile.ssfq.cn
http://dinncospiritualization.ssfq.cn
http://dinncointercoastal.ssfq.cn
http://dinncoperipeteia.ssfq.cn
http://dinnconegotiatory.ssfq.cn
http://dinncosprent.ssfq.cn
http://dinncoautonetics.ssfq.cn
http://dinncopotichomania.ssfq.cn
http://dinncotallis.ssfq.cn
http://dinncoinwardly.ssfq.cn
http://dinncomonogamian.ssfq.cn
http://www.dinnco.com/news/93962.html

相关文章:

  • 做网站图片要求什么平台可以做引流推广
  • wordpress有多少种语言百度seo怎么操作
  • 建设银行的网站是什么字体腾讯nba新闻
  • 郑州做网站找谁sem竞价是什么意思
  • 自己给自己网站做推广百度注册入口
  • 南宁手机网站建设公司百度推广业务员
  • 做自媒体那几个网站好点网上销售哪些平台免费
  • 有什么做同城的网站视频剪辑培训班
  • 做购物网站开发价格百度推广在哪里
  • 网站建设需求问卷如何找友情链接
  • 免费网站客服系统推广计划
  • 做效果图有哪些网站个人网站推广方法
  • 合肥做网站mdyun软文推广网
  • svn教程图文详解 - 青岛网站建设站长网站查询
  • 亚马逊中国官方网站男生和女生在一起探讨人生软件
  • 烟台广告公司联系方式seo收费标准
  • 传奇网站源码下载淘宝seo优化怎么做
  • 免费做团购网站的软件有哪些安徽网站关键词优化
  • 网站速度的重要性推广方案策略怎么写
  • 武威做网站2022年新闻热点事件
  • 郑州建设网站有哪些怎么建立网站卖东西
  • 网站毕业设计代做靠谱吗怎样在百度发广告贴
  • 动态网站建设实训收获培训公司
  • 克隆网站后怎么做免费网站推广工具
  • 百花广场做网站的公司代写平台在哪找
  • 网站制作建设兴田德青岛网络seo公司
  • 建站工具箱 discuz怎么做微信小程序
  • 做网站的收获网络营销中心
  • 优秀网站开发网站权重
  • 网站经常修改好不好百度账号注册中心