MySQL Note

2023-11-12

一 MySQL动作关键字

1.1 create
用途:创建index,procedure/function,schema,table
语法:

/* index
create [unique|fulltext|spatial] index index_name [using "index_type"]
on tbl_name(index_col_name,...)
[index_option]...
#index_col_name:
	col_name[(length)][asc|desc]
#索引类型
	unique  唯一索引,允许为null
	fulltext 全文索引
	spatial  空间索引
*/
mysql> create unique index index_name 
	using btree 
	on customers(customername(5) asc); 
	
/* procedure/function
create 
	[definer={user|current_user}]
	procedure sp_name([proc_parameter[,...]]
	[characteristic ...] routing_body
create
	[definer={user|current_user}]
	function sp_name([func_parameter[,...])
	returns type
	[characteristic ...] routine_body
#proc_parameter:
	[in|out|inout]param_name type
#func_parameter:
	param_name type
#routine_body:
	valid sql procedure statement
#delimiter定义分隔符
*/
mysql> delimiter //
 create 
 	definer = root
	procedure getallcustomers(inout test int)
	sql security definer
    	begin
  		select * from customers;
	 end//
delimiter ;

mysql> delimiter //
create
	definer = root
	function getallcustomers(test int)
	returns int
	sql security definer
	begin 
		select * from customers;
	end//
delimiter ;

/*schema
creart
	{database|schema} [if not exists] db_name
	[create_specification]...
#create_specication:
	[defualt]character set [=] charset_name	//字符集设置
	|[defualt]collate [=] collation_name		//校正设置
*/
mysql>create database test;

/*
create
	[or replace]
	[algorithm={undefined|merge|temptable}]	//算法
	[definer={user|current_user}]			
	[sql security{definer|invoker}]
	view view_name[(column_list)]
	as select_statement
	[with [cascaded|local] check option]
*/
mysql>create view [current product list] 
as select productid,productname from products where discontinued = no
mysql>select * from [current product list]

/*
create [temporary] table [if not exists] tbl_name
	{like old_tbl_name | (like old_tbl_name)}
*/
mysql>cteate table `new table` like old_test;

1.2 use
用途:选定database
语法:

//use database_name
mysql>use database_name;

1.3 drop
用途:删掉目标
语法

/*
drop [temporary] table [if exists]
	tbl_name [,tbl_name]...
	[restrict|caseade]	
 - restrict 确保无关联约束才删除
 - caseade  一并删除相关约束
*/
myspl>drop table table_name;

/*
drop view [if exists]
	view_name [,view_name]...
	[restrict|cascade]
*/
mysql>drop view view_name;

1.4 insert
用途:往表中添加新的数据
语法

/*
insert into table_name(field1,field2...) values(value1,value2...);
*/
mysql>insert into tbl_name(col1,col2) values('a',"abc");

1.5 select
用途:查询表
语法

/*
select
	column1,column2
from 
	table1
[inner | left | right] join table2 on conditions
where
	conditions
group by column1
having group_conditons
order by column1
limit offset,length;

from: sepecifies the table or view
join: gets related data from other tables based on specific join conditons
where: clause filters row
group by: clause groups a set of rows into groups and aggregate functions on each group
having: clause filters group based on groups defined by group by clause
order by: clause specifies a list of columns for sorting 
limit: constrains the number of returned rows
note-select and from clauses are required and other parts are optional
*/	
mysql>select `firstname`,`lastname`,`jobtitle` from `employees`;
mysql>select * from `employees`;
mysql>select
`officecode`,`city`,`phone`,`country`
from
`offices`
where
`country` in ('USA','France');  //key word "in"
mysql>select
`officecode`,`city`,`phone`,`country`
from
`offices`
where
`country`='usa' or `country`='france'; //key word "or"
mysql>select
`officecode`,`city`,`phone`,`country`
from
`offices`
where
`country` not in('usa','france'); //key word "not"
mysql>select
`ordernumber`,`customernumber`,`status`,`shippeddate`
from
`orders`
where
`ordernumber` in
(
select
`ordernumber`
from
(
select
`ordernumber`,sum(`quantityordered`*`priceeach`) as `totalcost`
from
`orderdetails`
group by
`ordernumber`
)
as a	//key word "as"
where
(a.`tatalcost`>60000)
)

1.6 like
用途:模板查询
语法

/*
%:match any srting
_:match any single character
*/
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`firstname` like 'a%';//key word '%'
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`lastname` like '%on';
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`lastname` like '%on%';
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`firstname` like 'T_m';
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`firstname` not like 'B%';//note '%' 不区分大小写
mysql>select
`productcode`,`productname`
from 
`products`
where
`productcode` like '%\_20%';//key word '\'
mysql>select
`productcode`,`productname`
from
`products`
where
`productcode` like '%$_20%' escape '$';//key word "escape"

二 MySQL内容关键字

2.1 index
用途:索引(在存储引擎层实现)
分类:

索引方法 \引擎 MyISAM InnoDB Memory
B-Tree 支持 支持 支持
HASH 不支持 不支持 支持
R-Tree 支持 不支持 不支持
Full-Text 支持 支持 不支持

例句解析:

mysql> show index from tbl_name;
/*result
table			表名称	
non_unique		索引不唯一
key_name		索引名称
seq_in_index	索引中列序列号
colummn_name	列名称
collation		列存储在索引的方式(A-升序;D-降序;null-无分类)
cardinality		索引中唯一值的数目的估计值(analyze table或myisamchk -a可以更新)
sub_part		如果列只是部分的编入索引,则是被编入索引的字符的数目。如果整列被编入索引,则为null
packed			指示关键字如何被压缩(null-没有压缩)
index_type		索引方法
comment			更多评注
*/

索引的原则:

  • 较频繁的作为查询条件的字段应该创建索引
  • 唯一性太差的字段不适合单独创建索引
  • 更新频繁的字段不适合创建索引
  • 记录不超过2000的可以不考虑创建索引
    2.2 key
    用途:数据库的物理结构,用于约束(数据库的结构完整性)和索引(辅助查询)
    包含:primary key,unique key,foreign key等
    • primary key: 唯一标识数据库表中的每一条记录,非空唯一
    • unique key: 约束作用,可空唯一
    • foreign key: 约束作用(不能直接用,需要先用key定义)
      语法:
mysql> ... primary key(col_name),key user(userid),...

2.3 constraint
用途:设定约束
语法:

mysql>...constraint `customers_ibfk_l` foreign key (`salserepemployeenumber`) references `employees`(`employeenumber`)...

2.4 engine
用途:建表时制定存储引擎
语法:

mysql>...engine = InnoDB...

2.5 charset
用途:建表时指定字符集
语法:

mysql>...charset=latin1;

三 seciton querying data

3.1 select
3.2 select distinct

in order to:remove the duplicate rows
syntax:

select distinct
	columns
from 
	table_name
where
	conditions;

example:

//example1
mysql>select distinct
`lastname`
from
`employees`
order by `lastname`
//example 2
mysql>select distinct
`state`,`city`
from
`customers`
where
`state` is not null
order by `state`;
//example 3
mysql>select 
count(distinct `state`)
from
`customers`
where
`countyr`='usa`;
//example 4
mysql>select distinct
`state`
from
`customers`
limit 5;

similar syntax:
distinct vs group by
i distinct clause is a special case of the group by clause

note:
i null 也是distinct的操作对象之一
ii 多个列操作时,当且仅当每个列都一样时,才被disdinct视为重复的对象

四 section filtering data

4.1 where
order to:specify the search condition fro the rows returned by the query
syntax:

select
	select_list
from
	table_name
where
	search_conditon;

example:

//example1
mysql>select
`lastname`,`firstname`,`jobtitle`
from
`employees`
where
`jobtitle`='sales rep';
//example2
mysql>select
`lastname`,`firstname`,`jobtitle`
from
`employees`
where
`jobtitle`='sales rep' and `offcecode`='1';

note:
1 the follow table shows the comparision operators than you can use in where clause

operator description
= equal to
<> or != not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to

4.2 and
order:logice operator
syntax:

where boolean_expression1 and boolean_expression2

example:

//example1
mysql>select
1=0 and 1/0;
//example2
mysql>select
`customername`,`country`,`state`
from
`customers`
where
`country`='usa' and `state`='ca';

note:
1 真值表

true false null
true true false null
false false false false
null null false null

4.3 or
in order to:logical operator
syntax:

boolean_expression_1 or boolean_expression_2

example:

//example1
mysql>select 1=1 or 1/0;
//example2
mysql>select
`customername`,`country`
from
`customers`
where
(`country`='usa' or `country`='france') and `creditlimit`>100000;

note:
1 真值表

true false null
true true true true
false true false null
null true null null

2 and 的优先级高于or
4.4 in
order to:logic operator
syntax:

select
	column1,column2...
from
	table_name
where
(expr|column1) in ('value1','value2'...);

example:

//example1
mysql>select
`officecode`,`city`,`phone`,`country`
from
`offices`
where
`country` in ('usa','france');

4.5 between
order to:logic operator
syntax:

expr [not] between begin_expr and end_expr

example:

mysql>select
`productcode`,productname`,`buyprice`
from
`products`
where
`buyprice` between 90 and 100;
//example2
mysql>select 
`ordernumber`,`requireddate`,`status`
from
`orders`
where
`requiredate` between ('2003-01-01' cast as date) and ('2003-01-31' cast as date)

note:
1 between 不能直接支持date数据,需要使用cast as将string转换成date

4.6 like
order to:模糊查询
i ‘_’ single character
ii ‘%’ any string
syntax:

expr where column1 like col_expr

example:

//example1
mysql>select
`employeenumber`,`lastname`,`firstname`
from
`employees`
where
`lastname` like '%a_';
//example2
mysql>select
`productcode`,`productname`
from
`products`
where
`productcode` like '%$_20%' escape '$';

note:
i \是转义符
ii escape可以定义其他符号为转义符

4.7 limit
order to:constrain the number of rows returned by select statement
syntax:

select
column1,column2,...
from
table
limit offset,count;

example:

//example1
mysql>select
`customernumber`,`customername`,`creditlimit`
from
`customers`
limit 1,10;
//get the highest and lowest values
mysql>select
`customernumber`,`customername`,`creditlimit`
from
`customers`
order by `creditlimit` desc
limint 5; 

note:
i the first offerset is 0,not 1
ii if there is only one argument,the argument must be count

4.8 is null
order to:test whether a value is null or not by using is null operator
syntax:

value is [not] null

example:

//example1
mysql>select 1 is null;
//example2
mysql>select `customername`,`country`,`salesrepemployeenumber`
from `customers`
where `salesrepemployeesnumber` is not null
order by `custumername`;

note:
i if the date or datetime column has not null constraint,you can use the is null to find the rows whitch is ‘0000-00-00’

section 4 sorting data
4.1 order by
order to:sort the result
syntax:

select column1,column2,..
from tbl1
order by column1 [asc|desc],column2 [asc|desc],...

example

//example1
mysql>select `contactfirstname`,`contactlastname`
from `customers`
order by `contactfirstname` asc,`contactlastname` desc;
//example2
mysql>select `ordernumber`,`orderlinenumber`,`quantityordere`*`priceeach` as `cost`
from `orderdetails`
order by `ordernumber`,`orderlinenumber`,`cost`;
//order by with custom sort order
mysql>select `ordernumber`,`status`
from `orders`
order by field(`status`,'inprocess','on hold','cancelled','resulved','disputed','shipped');

note:
1 field如果没有包含所有子项,则优先非被包含子项排列

section 5 joining tables

5.1 mysql alias
order to:alias and aliases to improve the readablility of complex queries
i table alias
ii column alias
syntax:

select [column1 | expression] as descriptive_name
from table_name;

table_name as table_alias;

example:

//example1
mysql>select concat_ws(' ',`firstname`,`lastname`)
as `full name`
from `employees`
//example2
mysql>select `ordernumber` `order no`,sum(`priceeach`* `quantityordered`) total
from `orderdetails`
group by `ordre no`
having `total` >60000;
//example3
mysql>select customername count(o.ordernumber) total
from `customers` c
inner join `orders` o on c.`customernumber`=o.`custmernumber`
group by `customername`
order by `total` desc;

5.2 mysql join
orderto:give an overview of joins

id pattern
1 divot
2 brick
3 grid
id pattern
A brick
B grid
C diamond

i cross join
在这里插入图片描述
ii inner join
在这里插入图片描述
iii left join

在这里插入图片描述
iv right join
在这里插入图片描述

syntax

//cross join
select *
from t1
	cross join t2;
	
//inner join
select column_list
from t1
inner join t2 on join_conditon1
inner join t3 on join_condition2
...
where where_conditons;
	
//left join(左边为主表)
select t1.c1,t1.c2,t2.c1,t2.c2
from t1
	left join t2 on t1.c1=t2.c1;	

example:

//inner join
mysql>select productcode,productname,textdescription
from products t1
	inner join productlines t2 on t1.productline=t2.prodcutline;

mysql>select productcode,productname,textdescription
from products
	inner join productlines using(productline);

mysql>select ordernumber,productname,msrp,priceeach
from products p
	inner join orderdetails o using(productcode)
	and p.msrp>o.priceeach
where p.productcode='s10_1678'
//left join
mysql>select o.ordernumber,customernumber,productcode
from orders o
	left join orderdetails d using(ordernumber) and d.productcode='s10_1678'

note
i 不同表含有同名行需要点名主表
ii on后面带有and条件时,显示主表信息以及从表and条件下的信息,其他信息显示null

5.2 self join
orderto:joins a table to itself using table alias
syntax:

inner join

example:

mysql>select
concat(m.lastname,',',m.firstname) as `mannager`,
concat(e.lastname,',',e.firstname) as `derect report`
from employees e 
 	inner join employees m on m.employeenumber=e.reportsto
order by mannager;
mysql>select ifnull(caoncat(m.lastname,',',m.firstname),'top manager') as manager,concat(e.lastname,','e.firstname) as 'direct report'
from employees
	left join employees m on m.employeenumber = e.reportsto
order by manager desc;

section 6
6.1 group by
orderto:show you how to group rows into group based on columns or expressions
syntax:

select c1,c2....
from table
where conditon
gorup by c1,c2...

example:

mysql>select status
from orders
group by status;
mysql>select status,count(*)
from orders
group by status;
mysql>select status,sum(quantityordered*priceeach) amount
from orders
	inner join orderdetails using(ordernumber)
group by stutas;
mysql>select year(orderdate) 'year',sum(quantityordered*priceeach) total
from orders
	inner join orderdetails using(ordernumber)
where status='shipped'
group by year
having year>2003;

6.2 having
orderto:filter the groups by a specific conditon
syntax:

expr 
having conditon;

example

mysql>select ordernumber sum(quantityordered) itemscount,sum(priceeach*quantityordered) total
from orderdetails
group by ordernumber
having total>1000 and itemscount>600

6.3 rollup
orderto:generate multiple grouping sets considering a hierarchy between columns specified in the group by clause(总计)
syntax:

select list
from table
group by c1,c1,c3 with rollup;

example

mysql>select 
	if(grouping(orderyear),'all years',orderyear) order year,
	if(grouping(rpductline),'all product lines',productline) productline,
	sum(ordervalue) totalordervalue
from sales
group by orderyear,productline with rollup;

在这里插入图片描述
section 7
7.1 subquery
orderto:嵌套
syntax:…
example:

mysql>select lastname,firstname
from employees
where officecode in(
select officecode
from offices
where country='usa');
mysql>select customernumber,checknumber,amount
from payments
where amount=(
	select max(amount)
	from payments);
mysql>select customername
from customers
where customernumber not in(	
	select distinct customernumber
	from orders);
mysql>select max(items),min(items),floor(avg(items)),avg(items)
from (select ordernumber,count(ordernumber) as items
from orderdetails
group by ordernumber) as lineitems;
mysql>select ordernumber,count(ordernumber) as items
from orderdetails
group by ordernumber;
mysql>select productname,buyprice
from products p1
where buyprice>(select avg(buyprice)
	from products
	where productline=p1.productline);
mysql>select customernumber,customername
from customers
where exists(select ordernumber,sum(priceeach*quantityordered) total
	from orderdetails
		inner join orders using(ordernumber)
	where customernumber=customers.customernumber
	group by ordernumber
	having total>60000;

note:
i 嵌套表必须加以别名
7.2 derived table
orderto:introduce you the derived table concept and show you how to use it to simplify complex queries
syntax:…
example:

mysql>select productname,sales
(select productcode,round(sum(quantityordered*priceeach)) sales
from orderdetails
	inner join orders using(ordernumber)
where year(shippeddate)=2003
group by productcode
order by sales desc
limit 5) top5products2003
inner join products using(productcode)
mysql>select customergroup,count(cg.customergroup) groupcount
from(select customernumber,round(sum(quantityordered*priceeach)) sales,
(case
	when sum(quantityordered*priceeach)<10000 then 'silver'
	when sum(quantityordered*priceeach) between 10000 and 100000 then 'gold'
	when sum(quantityordered*priceeach)>100000 then 'platinum'
	end) customergroup
	from orderdetails
		inner join orders using(ordernumber)
	where year(shippeddate)=2003
	group by customernumber) cg
group by cg.customergroup;

7.3 mysql cte
orderto:explain you the common table expression concept and show you how to use cte for querying data from tables(预定义明确语句)
syntax:

with cte_name (column_list) as(
query
)
select * from cte_name;

example:

mysql>with customers_in_usa as(select customername,state
from customers
where country = 'usa')
select customername
from customers_in_usa
where state='ca'
order by customername;
mysql>with recursive cte_count(n) as (slect 1
union all
select n+1
from cte_count
where n<3)
select n
from cte_count;
mysql>with recursive cte_count (n) as(select 1
union all
select n+1
from cte_count
where n<3)
slect n
from cte_count;

在这里插入图片描述

mysql>WITH RECURSIVE employee_paths AS  ( SELECT employeeNumber,reportsTo managerNumber,officeCode, 1 lvl   
FROM employees   
WHERE reportsTo IS NULL     
UNION ALL     
SELECT e.employeeNumber,e.reportsTo,e.officeCode,lvl+1     
FROM employees e     
	INNER JOIN employee_paths ep ON ep.employeeNumber = e.reportsTo )
SELECT employeeNumber,managerNumber,lvl,city
FROM employee_paths ep
INNER JOIN offices o USING (officeCode)
ORDER BY lvl, city;

note:
i the number of columns in the query must be the same as the number of columns in the column_list

section8 using set operators
8.1 union and union all
orderto:combine tow or more result sets of multiple queries into a single resualt set
syntax:

select column_list
union [distinct|all]
select column_list
union [distinct|all]
...

在这里插入图片描述
example:

mysql>select concat(firstname,' ',lastname) from employees
union
select concat(contactfirstname,'',contactlastname) from customers;

8.2 intersect
orderto:
show you a couple of ways to simulate the intersect operator
syntax:

(select column_list from t1)
interset
(select column_list from t2);

在这里插入图片描述
example:

mysql>select distinct id from t1
where id in(select id from t2);

8.3 minus
orderto:
explain to you the sql minus operator and show you to simulate it in mysql

syntax:

select column_list_1 from table_1
minus
select columns_list_2 from table_2

在这里插入图片描述

example:

mysql>select id from t1
minus select id from t2;

Section 9. Modifying data in mysql
9.1 insert
orderto:
insert data into a table

syntax:

insert into table(colunm_list) values(value_list),(value_list2),...

example:

mysql>insert into tasks(title,priortity) values('learn mysql',default);
mysql>insert into suppliers(suppliername,phone)
select customername,phone from customers 
	where contry='usa' and state='ca';
//using warning insteads error
mysql>insert ignore into subscribers(email) value('jonh@gmail.com'),('jane@ibm.com');

9.2 update
orderto:
update data in database tables

intax:

update [low_priority][ignore] table_name 
set column1=expr1,column2=expr2,...
[where condition];

example:

mysql>update employees set 
lastname='hill',
email ='mary.patterson@classicmodelcars.com'
where employeenumber=1056;
mysql>update customers set
salesrepemployeenumber=(
select employeenumber from employees
where jobtitle='sales rep'
order by rand()
limit 1)
where salesrepemployeenumber is null;
mysql>update employees inner join merits using(performance) set
	salary=salary+salary*percentage;

note:
1 the low_priority modifier instructs the update statement to delay the update until there is no connection reading data from the table
2 the ignore modifier enables the update statement to continue updating cows even if errors occurrend.the rows that cause errors such as duplicate-key conflicts are not updated

9.3 Delete
orderto:remove data from one or more tables

syntax:

delete from table_name
[where conditon];

delete t1,t2 from t1
	inner join t2 on t2.ref=t1.id
where t1.id=1;

example:

mysql>delete from customers
	where country='france'
	order by customername
	limit 5;
mysql>create table roos(
	room_no int primary key auto_increment,
	room_name varchar(255) not null,
	building_no int not null,
	foreign key(building_no) references buildings(building_no) on delete cascade);

note:使用串联删除的前提是外键声明可串联删除
9.4 replace
orderto:replace the data to null

syntax:

replace into table_name(column_list) values(value_list)

replace into table_name	
	set col1=value1,col2=value2;

note:
i 如果表中含有声明的values,则对应的行其他values将改为null
ii 如果表中不含有声明的values,则等效于建立新的行
Section 10 mysql transaction
10.1 mysql transaction
orderto:learn the commit and rollback

sytax:

//set autocommit = off
start transaction;
...
commit;
rollback;

10.2 table locking
orderto:
locking the table

syntax:

lock tables table_name [read | write];

unlock tables;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MySQL Note 的相关文章

  • #pragma once和#ifndef的作用和区别

    两者共同的作用 防止库文件重复包含 ifndef define endif 方法一 在 h头文件开头加上 pragma once add h pragma once int ADD x y 方法二 在 h头文件加上预定义指令 add h i
  • Python-Anaconda最新安装图文教程

    Anaconda简介 Anaconda是一种数据科学和机器学习的开发环境 它包含了大量的Python包 工具和库 以及可视化界面和集成开发环境 Anaconda可以方便地管理Python环境和安装第三方软件包 同时也支持多个操作系统和平台
  • vue 组件通信方式你知道几种,这6种一定得掌握

    第一种props 适用于的场景 父子组件通信 注意事项 如果父组件给子组件传递数据 函数 本质其实是子组件给父组件传递数据 如果父组件给子组件传递的数据 非函数 本质就是父组件给子组件传递数据 书写方式 3种 todos type Arra
  • PTP(Precision Time Protocol)高精度时间同步协议+CS模式测试代码

    Precision Time Protocol PTP 一 什么是PTP PTP 是一种高精度时间同步协议 可以到达亚微秒级精度 有资料说可达到30纳秒左右的偏差精度 但需要网络的节点 交换机 支持PTP协议 才能实现纳秒量级的同步 一般在
  • 深入浅出 redux中间件

    redux中间件是什么 理解redux中间件首先我们需要理解redux是什么 Redux是JavaScript应 的状态容器 它保证程序 为 致性且易于测试 当业务足够复杂时 我们就需要使用redux来存储我们的多页面共同数据 redux的
  • 现行安全存储策略-密码加盐

    本文描述了本人 对于数据库中如何保存密码的认识过程 从最简单的明文保存到密码加盐保存 下面与大家分享下 第一阶段 最开始接触web开发时 对于用户表的密码基本是明文保存 如 username password zp1996 123456 z
  • 利用js实现简单抽奖功能

    其实这种抽奖的功能和选人是一样的 在点击开始按钮之后 标题上方的名字可以实现一个不停的变化 在点击停止之后抽出获奖的名字 在写之我们必须明确一点的是需要用到哪些方法 并且将基础的框架搭建出来 下面是功能实现的视频展示 如下 抽奖 基本的样式
  • OpenCv案例(四): 基于OpenCvSharp对图像轮廓提取与面积和周长计算

    1 需求 提取图像中物体的轮廓以及计算该面积和周长 2 详细代码如下 public static void GetOutline try region 加载图像 Mat src Cv2 ImRead srcImg bmp if src Em
  • python连接Oracle数据库代码

    import cx Oracle as oracle db oracle connect 用户名 密码 IP 端口号 SERVICE NAME db oracle connect admin password IP 1521 DataBas
  • 微信小程序把页面做成图片分享【原创】

    开发微信小程序的时候 经常要遇到如上图这样的 保存小程序二维码图片的分享功能 网上找了很多都没有具体的写法 于是自己看官方文档写了一个 分享一下 首先 需要在 wxml 中 创建一个 画板 canvas wxml
  • Matlab 绘制虚数和复数数据图

    Matlab 绘制虚数和复数数据图 在 Matlab 中 我们可以使用 plot 函数来绘制实数数据图 但是当数据包含虚部时 我们需要使用另一种方式来绘制 Matlab 中的虚数和复数数据可以用两种方式表示 一种是把虚数表示为 i 即 j
  • 6.3-训练DNN的技巧

    文章目录 一 新的激活函数 New activation function 1 1 校正线性单元 Rectified Linear Unit 1 2 Maxout 二 自适应学习率 Adaptive Learning Rate 2 1 Mo
  • 红帽子Linux6.5 X86_64 自动重启解决办法

    机器重启前的15分钟 都会有一个报错 usr sbin bmc watchdog fiid obj get present countdown value data not available redhat对此有说明https access
  • qt中的tableView中的排序

    一 第三列的排序方式 1 第3列是按照升序来排列 ui gt tableView gt sortByColumn 3 Qt AscendingOrder 第3列是按照升序来排列 ui gt tableView gt setSortingEn
  • 弱网测试—Network-Emulator-Toolkit

    弱网测试 属于健壮性测试 怎么样去做弱网测试呢 一 安装弱网测试工具 Network Emulator Toolkit 推荐一个工具 Network Emulator Toolkit 这个工具的作用主要是设置丢包率和延时 1 安装与卸载 下
  • 怎么使用Web3.js开发一个简单的Dapp

    通过这篇文章 我们将学习 Dapps 和 Web3js 的基础知识 让我们了解一下基本术语 区块链 去中心化应用程序 以太坊 智能合约 web3js 区块链 区块链是一个可审计且不可逆的数据库 其中数据只能添加 在区块链中 数据可以作为块添
  • elasticSearch详细教程

    一 Elasticsearch简介 Elasticsearch是使用Java编写的一种开源搜索引擎 它在内部使用Luence做索引与搜索 通过对Lucene的封装 提供了一套简单一致的RESTful API Elasticsearch也是一
  • 数据结构中Java实现KMP与BF算法对比

    public class KMPANDBF public int indexBfCount SeqString s SeqString t int begin int slen tlen i begin j 0 int count 0 sl
  • Scipy

    10 1 import numpy as np import scipy optimize as opt m 20 n 10 A np random normal loc 10 scale 3 size m n b np random no
  • 【C语言】#文件操作#有5个学生,每个学生有3门课程的成绩,从键盘输入以上数据(包括学号、姓名、3门课成绩),计算出平均成绩,将原有数据和计算出的平均分数存放在磁盘文件stud中。

    题目 1 有5个学生 每个学生有3门课程的成绩 从键盘输入以上数据 包括学号 姓名 3门课成绩 计算出平均成绩 将原有数据和计算出的平均分数存放在磁盘文件stud中 设5名学生的学号 姓名和3门课成绩如下 在向文件stud写入数据后 应检查

随机推荐

  • Python 正则表达式RE知识学习

    正则表达式 Regular Expression 是一种强大的文本模式匹配工具 常用于在字符串中查找 替换 分割等操作 在 Python 中 可以使用内置的 re 模块来操作正则表达式 ChatGPT编写 下面是一些需要掌握的正则表达式知识
  • 《大五人格心理学》读书笔记

    这本书介绍了一下职场中的大五人格 具有不同人格特质的人适合干不同的工作 了解自己的人格特质 有利于自己的职业规划 了解同事的人格特质 有利于合作 1 宜人性 宜人性的心声 这对他人有什么影响VS 这对我有什么价值 宜人性的子维度 同理心 经
  • Nginx实现404页面的几种方法

    Nginx实现404页面的几种方法 第一种 Nginx自己的错误页面 第二种 反向代理的错误页面 第三种 Nginx解析php代码的错误页面 第四种 指定一个url地址 第一种 Nginx自己的错误页面 Nginx访问一个静态的html 页
  • JAVA单元测试框架-12-java代码重复执行失败的测试用例

    在使用testng执行测试用例时候 都会遇到测试用例执行失败 怎么再次执行失败的测试用例呢 官网给出了java代码执行测试的案例 每次执行完用例后会在test output目录路径下保存执行失败的测试用例 可以再次执行失败的测试用例来达到重
  • QT实现中英文键盘

    使用Qt中实现中英文键盘 支持各种linux嵌入式设备 实现思路 需要一个中文字体库 将字体库加载到一个Hash容器 字母和拼音作为key值 对应的中文作为value值 核心代码 include UKeyBoard h include ui
  • CSDN-markdown编辑器

    这里写自定义目录标题 欢迎使用Markdown编辑器 新的改变 功能快捷键 合理的创建标题 有助于目录的生成 如何改变文本的样式 插入链接与图片 如何插入一段漂亮的代码片 生成一个适合你的列表 创建一个表格 设定内容居中 居左 居右 Sma
  • 使用高德地图 vue-amap 中遇到的问题

    1 搜索组件进行搜索的时候 无论搜索哪个城市 地图一直固定在一个城市 我的是深圳
  • 基于Docker环境安装ElasticSearch

    1 搜索技术 搜索技术在我们日常生活的方方面面都会用到 例如 综合搜索网站 百度 谷歌等 电商网站 京东 淘宝的商品搜索 软件内数据搜索 我们用的开发工具 如Idea的搜索功能 这些搜索业务有一些可以使用数据库来完成 有一些却不行 因此我们
  • 【Java进阶篇】—— File类与IO流

    一 File类的使用 1 1 概述 File 类以及本章中的各种流都定义在 java io 包下 一个File对象代表硬盘或网络中可能存在的一个文件或文件夹 文件目录 File 能新建 删除 重命名 文件和目录 但 File不能访问文件内容
  • 数据结构视频教程 -《[北风网]C#版数据结构与算法高级教程》

    整个视频打包下载地址 史上最全的数据结构视频教程系列分享之 北风网 C 版数据结构与算法高级教程 转载请保留出处和链接 更多优秀资源请访问 我是码农 数据结构是计算机存储 组织数据的方式 数据结构是指相互之间存在一种或多种特定关系的数据元素
  • Redis可视化工具无法连接Redis(安装在服务器上面)的解决方案

    redis可视化工具连接安装在阿里云上面的redis时 一直连接不上 你可以按下面三步去完美解决 第一 确保redis正常启动 我这主要解决redis可视化工具无法连接redis哈 具体redis安装我就不讲了奥 首先通过指令 cd usr
  • 区块链共识机制技术一——POW(工作量证明)共识机制

    什么是共识机制 所谓 共识机制 是通过特殊节点的投票 在很短的时间内完成对交易的验证和确认 对一笔交易 如果利益不相干的若干个节点能够达成共识 我们就可以认为全网对此也能够达成共识 区块链作为一个去中心化的分布式账本系统 然而在实际运行中
  • RPC通信基本原理 -- 浅析RPC远程过程调用基本原理

    一 RPC基本概念 1 1 RPC简介 RPC 的全称是 Remote Procedure Call是一种进程间通信方式 RPC只是一个概念 而不是具体的协议或框架 它允许程序调用另一个地址空间 通常是共享网络的另一台机器上 的过程或函数
  • 应用布尔盲注来爆库(1)

    先上道练习题Less 8 打开sqli labs项目的练习题Less 8 http 192 168 3 2 sqli labs Less 8 然后输入id 1参数 可以得到以下信息 输入有效id 1时 只提示成功 You are in 没有
  • 基於RISC-V QEMU 仿真運行Linux 系統環境搭建

    前言 文章詳細說明如何從堶零開始基於RISC V QEMU 仿真運行Linux 系統環境搭建 是Linux 小白入門教程不二之選 歡迎留言討論 轉發請注明原文出處 1 準備QEMU 仿真環境 RISC V 64bits 安裝包下載地址 ht
  • 【华为OD机试】猴子爬山 (C++ Python Java)2023 B卷

    时间限制 C C 1秒 其他语言 2秒 空间限制 C C 262144K 其他语言524288K 64bit IO Format lld 语言限定 C clang11 C clang 11 Pascal fpc 3 0 2 Java jav
  • 红米Note 4超简单刷成开发版获取ROOT权限的流程

    小米的设备不同手机型号一般miui论坛都提供两个不同的系统 可分为稳定版和开发版 稳定版没有提供root超级权限管理 开发版中就开启了root超级权限 较多时候我们需要使用的一些功能强大的应用 都需要在root超级权限下工作 举个栗子我们团
  • python 列表(list)排序

    使用python的sorted函数 可对列表进行排序 该函数默认从小到大排序 1 列表中为普通元素 a 80 85 90 100 a sorted a sorted函数默认从小到大排序 print a 输出结果 80 85 90 100 倒
  • RIA项目失败的教训

    作者 Abel Avram 译者 崔康 发布于 2009年7月22日 上午11时6分 社区 Architecture Java 主题 可用性 用户界面 RIA 富客户端 桌面 EffectiveUI公司主席Anthony Franco最近做
  • MySQL Note

    一 MySQL动作关键字 1 1 create 用途 创建index procedure function schema table 语法 index create unique fulltext spatial index index n