mysql 内置函数

目录

日期函数

current_date

current_time

current_timestamp

date

now

date_add

date_sub

datediff

字符串函数

charset

concat

instr

ucase

lcase

left

length

replace

strcmp

substring

ltrim/rtrim/trim

ltrim

rtrim

trim

数学函数

abs

bin

hex

conv

ceiling

floor

format

rand

mod

其他函数

database

ifnull

md5

password


前面提到过 mysql 是有自己的函数的,下面看一下 mysql 常用的函数

日期函数

函数名称描述
current_date()当前日期
current_time()当前时间
current_timestamp()当前时间戳
date(datetime)返回datetime参数的日期部分
date add(date, interval d value_type)在date中添加日期或时间interval后的数值单位可以是: year minute second day
date sub(date, interval d value type)在date中添加日期或时间interval后的数值单位可以是: year minute second day
datediff(datel, date2)两个日期的差,单位是天
now()当前日期时间

上面就是常见的日期函数,下面来看日期函数的使用。

current_date

创建一个生日表,里面有 id int 类型并且自增,还有 birthday date 类型:

mysql> create table t1(-> id int primary key auto_increment,-> birthday date);
Query OK, 0 rows affected (0.01 sec)
​
mysql> desc t1;
+----------+---------+------+-----+---------+----------------+
| Field    | Type    | Null | Key | Default | Extra          |
+----------+---------+------+-----+---------+----------------+
| id       | int(11) | NO   | PRI | NULL    | auto_increment |
| birthday | date    | YES  |     | NULL    |                |
+----------+---------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

创建完成后开始插入数据:

mysql> insert into t1(birthday) values('1990-01-01');
Query OK, 1 row affected (0.01 sec)
​
mysql> select * from t1;
+----+------------+
| id | birthday   |
+----+------------+
|  1 | 1990-01-01 |
+----+------------+
1 row in set (0.00 sec)

该日期可以直接手动插入,也可以使用前面的日期类函数:

mysql> insert into t1(birthday) values(current_date());
Query OK, 1 row affected (0.01 sec)
​
mysql> select * from t1;
+----+------------+
| id | birthday   |
+----+------------+
|  1 | 1990-01-01 |
|  2 | 2023-08-28 |
+----+------------+
2 rows in set (0.00 sec)

current_time

上面的函数,当前日期表示的就是 XXXX年YY月ZZ天,而时间就是具体时间:

mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2023-08-28     |
+----------------+
1 row in set (0.00 sec)
​
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 20:54:52       |
+----------------+
1 row in set (0.00 sec)

current_timestamp

在 mysql 中时间戳并不是遗传数字,而是转化成了具体的时间:

mysql> select current_timestamp();
+---------------------+
| current_timestamp() |
+---------------------+
| 2023-08-28 20:56:04 |
+---------------------+
1 row in set (0.00 sec)

date 类型的数据不仅可以插入日期的类型,还可以插入具体时间:

mysql> select * from t1;
+----+------------+
| id | birthday   |
+----+------------+
|  1 | 1990-01-01 |
|  2 | 2023-08-28 |
|  3 | 2023-08-28 |
+----+------------+
3 rows in set (0.00 sec)
​
mysql> insert into t1(birthday) values(current_timestamp());
Query OK, 1 row affected, 1 warning (0.00 sec)
​
mysql> select * from t1;
+----+------------+
| id | birthday   |
+----+------------+
|  1 | 1990-01-01 |
|  2 | 2023-08-28 |
|  3 | 2023-08-28 |
|  4 | 2023-08-28 |
+----+------------+
4 rows in set (0.00 sec)

date

date 函数可以返回某一时间的日期:

mysql> select date('1990-01-01 22:50:31');
+-----------------------------+
| date('1990-01-01 22:50:31') |
+-----------------------------+
| 1990-01-01                  |
+-----------------------------+
1 row in set (0.00 sec)

可以手动输入,也可以使用其他函数:

mysql> select date(current_date());
+----------------------+
| date(current_date()) |
+----------------------+
| 2023-08-28           |
+----------------------+
1 row in set (0.00 sec)
​
mysql> select date(current_time());
+----------------------+
| date(current_time()) |
+----------------------+
| 2023-08-28           |
+----------------------+
1 row in set (0.00 sec)

now

now 就是返回当前时间

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2023-08-28 21:03:43 |
+---------------------+
1 row in set (0.00 sec)

其中 now 也可以使用 date 来截取当前日期:

mysql> select date(now());
+-------------+
| date(now()) |
+-------------+
| 2023-08-28  |
+-------------+
1 row in set (0.00 sec)

date_add

日期函数中还有可以计算某一日期加时间的:

mysql> select date_add('2023-01-01', interval 10 day);
+-----------------------------------------+
| date_add('2023-01-01', interval 10 day) |
+-----------------------------------------+
| 2023-01-11                              |
+-----------------------------------------+
1 row in set (0.00 sec)

该时间计算除了可以加天数,也可以加年、分、秒。

mysql> select date_add('2023-01-01', interval 10 minute);
+--------------------------------------------+
| date_add('2023-01-01', interval 10 minute) |
+--------------------------------------------+
| 2023-01-01 00:10:00                        |
+--------------------------------------------+
1 row in set (0.00 sec)
​
mysql> select date_add('2023-01-01', interval 10 second);
+--------------------------------------------+
| date_add('2023-01-01', interval 10 second) |
+--------------------------------------------+
| 2023-01-01 00:00:10                        |
+--------------------------------------------+
1 row in set (0.00 sec)

date_sub

上面是对时间进行加,还可以进行减,而且可以减去年、天、分、秒:

mysql> select date_sub('2023-01-01', interval 10 day);
+-----------------------------------------+
| date_sub('2023-01-01', interval 10 day) |
+-----------------------------------------+
| 2022-12-22                              |
+-----------------------------------------+
1 row in set (0.00 sec)

datediff

datediff 可以计算时间差:

mysql> select datediff('2023-08-28', '1980-01-01');
+--------------------------------------+
| datediff('2023-08-28', '1980-01-01') |
+--------------------------------------+
|                                15945 |
+--------------------------------------+
1 row in set (0.00 sec)

其中里面的参数可以使用函数:

mysql> select datediff(now(), '1980-01-01');
+-------------------------------+
| datediff(now(), '1980-01-01') |
+-------------------------------+
|                         15945 |
+-------------------------------+
1 row in set (0.01 sec)

datediff 里面的参数是第一个时间减去第二个时间:

mysql> select datediff('1980-01-01',now());
+------------------------------+
| datediff('1980-01-01',now()) |
+------------------------------+
|                       -15945 |
+------------------------------+
1 row in set (0.00 sec)

字符串函数

mysql 除了常用到日期函数,还常用到字符串函数。

函数名称描述
charset(str)返回字符串字符集
concat(string2 [,...])连接字符串
instr(string,substring)返回substring在string中出现的位置,没有返回0
ucase(string2)转换成大写
lcase(string2)转换成小写
left(string2, length)从string2中的左边起取length个字符
length(string)string的长度
replace(str, search str, replace str)在str中用replace_str替换search str
strcmp(stringl, string2)逐字符比较两字符串大小
substring(str, position [,length])从str的postion开始,取length个字符
ltrim(string) rtrim(string) trim(string)去除前空格或后空格

charset

该函数用于查看字符编码:

mysql> select charset('abcd');
+-----------------+
| charset('abcd') |
+-----------------+
| utf8            |
+-----------------+
1 row in set (0.00 sec)

我们的mysql 已经配置过了,默认就是 utf8 的编码。其中该函数不仅可以这样查看也可以查看表中的数据:

mysql> select * from employee;
+----+--------------+--------+--------------+----------+
| id | name         | gender | dept         | sal      |
+----+--------------+--------+--------------+----------+
|  1 | 孙悟空       | 男     | 安全部门     | 13000.00 |
|  2 | 玉皇大帝     | 男     | 政治部门     |  8000.00 |
|  3 | 女儿国王     | 女     | 辅助部门     |  5000.00 |
|  4 | 白骨精       | 女     | 辅助部门     |  4500.00 |
|  5 | 猪八戒       | 男     | 安全部门     | 10000.00 |
|  6 | 白龙马       | 男     | 交通部门     |  5500.00 |
|  8 | 观音菩萨     | 女     | 政治部门     | 15000.00 |
+----+--------------+--------+--------------+----------+
7 rows in set (0.00 sec)
​
mysql> select charset(name) from employee;
+---------------+
| charset(name) |
+---------------+
| utf8          |
| utf8          |
| utf8          |
| utf8          |
| utf8          |
| utf8          |
| utf8          |
+---------------+
7 rows in set (0.00 sec)

concat

该函数时用于字符串连接,在语言中也有部分这种函数,可能函数名并不一样:

mysql> select concat('a', 'b', 'c');
+-----------------------+
| concat('a', 'b', 'c') |
+-----------------------+
| abc                   |
+-----------------------+
1 row in set (0.00 sec)

该函数不仅可以连接字符串,也可以将数字也连接起来:

mysql> select concat('a', 'b', 'c', 99999, 0.1234);
+--------------------------------------+
| concat('a', 'b', 'c', 99999, 0.1234) |
+--------------------------------------+
| abc999990.1234                       |
+--------------------------------------+
1 row in set (0.00 sec)

可以看一下该函数的实际作用,下面我们可以查看exam_result 表中的学生成绩:

mysql> select concat('名字:', name, ',总分:',chinese+math+english, ',语文成绩:',chinese, '数学成绩:',math, '英语成绩:',english) as 成绩 from exam_result;
+--------------------------------------------------------------------------------------+
| 成绩                                                                                  |
+--------------------------------------------------------------------------------------+
| 名字:林黛玉,总分:287,语文成绩:98数学成绩:90英语成绩:99                                  |
| 名字:薛宝钗,总分:266,语文成绩:88数学成绩:90英语成绩:88                                  |
| 名字:赵姨娘,总分:262,语文成绩:79数学成绩:90英语成绩:93                                  |
| 名字:小白龙,总分:228,语文成绩:99数学成绩:110英语成绩:19                                 |
+--------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

instr

instr(a, b) 该函数查看 b 是否在 a 中,如果有的话,返回b在a中的的起始位置,否则返回0。

mysql> select instr('hello world', 'world');
+-------------------------------+
| instr('hello world', 'world') |
+-------------------------------+
|                             7 |
+-------------------------------+
1 row in set (0.00 sec)

ucase

该函数将小写转化为大写:

mysql> select ucase('abcd1234ABCD');
+-----------------------+
| ucase('abcd1234ABCD') |
+-----------------------+
| ABCD1234ABCD          |
+-----------------------+
1 row in set (0.00 sec)

lcase

该函数将大写转化为小写:

mysql> select lcase('abcd1234ABCD');
+-----------------------+
| lcase('abcd1234ABCD') |
+-----------------------+
| abcd1234abcd          |
+-----------------------+
1 row in set (0.00 sec)

left

left(string, length) 该函数从左边开始截取 string 的 length 个字符:

mysql> select left('hello world', 5);
+------------------------+
| left('hello world', 5) |
+------------------------+
| hello                  |
+------------------------+
1 row in set (0.00 sec)

如果length 大于该字符串原本长度,那么就是全部截取:

mysql> select left('hello world', 25);
+-------------------------+
| left('hello world', 25) |
+-------------------------+
| hello world             |
+-------------------------+
1 row in set (0.00 sec)

length

该函数用于查看字符串的长度,返回的时字节数:

mysql> select length('hello');
+-----------------+
| length('hello') |
+-----------------+
|               5 |
+-----------------+
1 row in set (0.01 sec)

开可以查看汉字:

mysql> select length('中国');
+------------------+
| length('中国')   |
+------------------+
|                6 |
+------------------+
1 row in set (0.00 sec)

我们的 mysql utf8,所以每个汉字占3个字节,其中 utf8 还是变长的:

mysql> select length('中国102');
+---------------------+
| length('中国102')   |
+---------------------+
|                   9 |
+---------------------+
1 row in set (0.00 sec)

replace

replace(string, search, raplace)该函数是替换,将 string 中的 search 的字符串替换成 replace 字符串:

mysql> select replace('中国制造','中国', 'china');
+-------------------------------------------+
| replace('中国制造','中国', 'china')       |
+-------------------------------------------+
| china制造                                 |
+-------------------------------------------+
1 row in set (0.00 sec)

strcmp

该函数就是字符串比较,若是前面大于后面返回1,相等则返回0,小于则返回-1:

mysql> select strcmp('abc', 'abd');
+----------------------+
| strcmp('abc', 'abd') |
+----------------------+
|                   -1 |
+----------------------+
1 row in set (0.00 sec)
​
mysql> select strcmp('abc', 'abc');
+----------------------+
| strcmp('abc', 'abc') |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)
​
mysql> select strcmp('abd', 'abc');
+----------------------+
| strcmp('abd', 'abc') |
+----------------------+
|                    1 |
+----------------------+
1 row in set (0.00 sec)

substring

sunstring(string, pos, length)该函数就是对 string 的pos 位置截取 length 长度的字符串:

mysql> select substring('hello world', 7, 5);
+--------------------------------+
| substring('hello world', 7, 5) |
+--------------------------------+
| world                          |
+--------------------------------+
1 row in set (0.00 sec)

left 只能从左边开始截取,而 substring 可以从任意位置开始。

ltrim/rtrim/trim

这几个函数是用来去掉空格的,ltrim 是去掉左边的空格,rtrim 是去掉右边的空格,trim就是去掉两边的空格,这几个函数都不会去掉中间的空格。

ltrim
mysql> select ltrim('          7   ****   8         ');
+------------------------------------------+
| ltrim('          7   ****   8         ') |
+------------------------------------------+
| 7   ****   8                             |
+------------------------------------------+
1 row in set (0.00 sec)
rtrim
mysql> select rtrim('          7   ****   8         ');
+------------------------------------------+
| rtrim('          7   ****   8         ') |
+------------------------------------------+
|           7   ****   8                   |
+------------------------------------------+
1 row in set (0.00 sec)
​

实际上这里去掉了,但是这里看的不明显,可以重命名一下:

mysql> select rtrim('          7   ****   8         ') as rtrim;
+------------------------+
| rtrim                  |
+------------------------+
|           7   ****   8 |
+------------------------+
1 row in set (0.00 sec)
trim
mysql> select trim('          7   ****   8         ') as trim;
+--------------+
| trim         |
+--------------+
| 7   ****   8 |
+--------------+
1 row in set (0.00 sec)

数学函数

函数名称描述
abs (number)绝对值函数
bin(decimal number)十进制转换二进制
hex(decimalNumber)转换成十六进制
conv(number,from base,to base)进制转换
ceiling(number)向上去整
floor(number)向下去整
format(number,decimal places)格式化,保留小数位数
hex(decimalNumber)转换成十六进制
rand()返回随机浮点数,范围[0.0,1.0)
mod(number, denominator)取模,求余

abs

abs 函数用于求绝对值:

mysql> select abs(10);
+---------+
| abs(10) |
+---------+
|      10 |
+---------+
1 row in set (0.00 sec)
​
mysql> select abs(-10);
+----------+
| abs(-10) |
+----------+
|       10 |
+----------+
1 row in set (0.00 sec)

除了整数,小数也可以:

mysql> select abs(10.11);
+------------+
| abs(10.11) |
+------------+
|      10.11 |
+------------+
1 row in set (0.00 sec)
​
mysql> select abs(-10.11);
+-------------+
| abs(-10.11) |
+-------------+
|       10.11 |
+-------------+
1 row in set (0.00 sec)

bin

十进制转化为二进制函数:

mysql> select bin(5);
+--------+
| bin(5) |
+--------+
| 101    |
+--------+
1 row in set (0.00 sec)
​
mysql> select bin(1);
+--------+
| bin(1) |
+--------+
| 1      |
+--------+
1 row in set (0.00 sec)
​
mysql> select bin(2);
+--------+
| bin(2) |
+--------+
| 10     |
+--------+
1 row in set (0.00 sec)

也可以是负数:

mysql> select bin(-1);
+------------------------------------------------------------------+
| bin(-1)                                                          |
+------------------------------------------------------------------+
| 1111111111111111111111111111111111111111111111111111111111111111 |
+------------------------------------------------------------------+
1 row in set (0.00 sec)

小数也可以:

mysql> select bin(1.1);
+----------+
| bin(1.1) |
+----------+
| 1        |
+----------+
1 row in set (0.00 sec)

但是这里的小数是取整了后转化的。

hex

十进制转化为十六进制:

mysql> select hex(15);
+---------+
| hex(15) |
+---------+
| F       |
+---------+
1 row in set (0.00 sec)
​
mysql> select hex(20);
+---------+
| hex(20) |
+---------+
| 14      |
+---------+
1 row in set (0.00 sec)

盎然这个函数也和 bin 函数一样,负数小数都可以。

conv

conv(number, format, base) number 表示哪一个数字,format 表示本来是几进制,base 表示转化为几进制:

mysql> select conv(5, 10, 10);
+-----------------+
| conv(5, 10, 10) |
+-----------------+
| 5               |
+-----------------+
1 row in set (0.00 sec)
​
mysql> select conv(5, 10, 2);
+----------------+
| conv(5, 10, 2) |
+----------------+
| 101            |
+----------------+
1 row in set (0.00 sec)
​
mysql> select conv(15, 10, 16);
+------------------+
| conv(15, 10, 16) |
+------------------+
| F                |
+------------------+
1 row in set (0.00 sec)

ceiling

向上取整:

mysql> select ceiling(1.1);
+--------------+
| ceiling(1.1) |
+--------------+
|            2 |
+--------------+
1 row in set (0.00 sec)
​
mysql> select ceiling(1.5);
+--------------+
| ceiling(1.5) |
+--------------+
|            2 |
+--------------+
1 row in set (0.00 sec)
​
mysql> select ceiling(1.9);
+--------------+
| ceiling(1.9) |
+--------------+
|            2 |
+--------------+
1 row in set (0.00 sec)

上面是正数向上取整,只要有小数,那么就会变大。

mysql> select ceiling(-1.9);
+---------------+
| ceiling(-1.9) |
+---------------+
|            -1 |
+---------------+
1 row in set (0.00 sec)
​
mysql> select ceiling(-1.5);
+---------------+
| ceiling(-1.5) |
+---------------+
|            -1 |
+---------------+
1 row in set (0.00 sec)
​
mysql> select ceiling(-1.1);
+---------------+
| ceiling(-1.1) |
+---------------+
|            -1 |
+---------------+
1 row in set (0.00 sec)
​

负数向上取整也是变大,对于负数来说绝对值越小则越大。

floor

向下取整:

mysql> select floor(1.1);
+------------+
| floor(1.1) |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)
​
mysql> select floor(1.5);
+------------+
| floor(1.5) |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)
​
mysql> select floor(1.9);
+------------+
| floor(1.9) |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)
​

向下取整也就是变小,不管小数点多大,都会向下变小。

mysql> select floor(-1.1);
+-------------+
| floor(-1.1) |
+-------------+
|          -2 |
+-------------+
1 row in set (0.00 sec)
​
mysql> select floor(-1.5);
+-------------+
| floor(-1.5) |
+-------------+
|          -2 |
+-------------+
1 row in set (0.00 sec)
​
mysql> select floor(-1.9);
+-------------+
| floor(-1.9) |
+-------------+
|          -2 |
+-------------+
1 row in set (0.00 sec)
​

对于负数的变小就是绝对值越来越大,而向下取整就是变小。

format

format(number, decimal_places) number 表示对哪一个数字进行格式化, decimal_place 表示有几位小数:

mysql> select format('3.1415926', 5);
+------------------------+
| format('3.1415926', 5) |
+------------------------+
| 3.14159                |
+------------------------+
1 row in set (0.01 sec)
​
mysql> select format('3.1415926', 2);
+------------------------+
| format('3.1415926', 2) |
+------------------------+
| 3.14                   |
+------------------------+
1 row in set (0.01 sec)

其中对整数也可以格式化:

mysql> select format('3', 2);
+----------------+
| format('3', 2) |
+----------------+
| 3.00           |
+----------------+
1 row in set (0.00 sec)

rand

该函数就是返回浮点数,范围是0~1:

mysql> select rand();
+--------------------+
| rand()             |
+--------------------+
| 0.7096299759201985 |
+--------------------+
1 row in set (0.00 sec)

如果想要10以内的浮点数,那么就可以乘10:

mysql> select rand()  * 10;
+--------------------+
| rand()  * 10       |
+--------------------+
| 5.6270866427822845 |
+--------------------+
1 row in set (0.00 sec)

要100以内的随机整数:

mysql> select format(rand()  * 100, 0);
+--------------------------+
| format(rand()  * 100, 0) |
+--------------------------+
| 68                       |
+--------------------------+
1 row in set (0.00 sec)

mod

mod(number, denominator) 该函数就是对 number 进行取模 :

mysql> select mod(100, 3);
+-------------+
| mod(100, 3) |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)
​
mysql> select mod(2, 3);
+-----------+
| mod(2, 3) |
+-----------+
|         2 |
+-----------+
1 row in set (0.00 sec)
​

除了正数取模,还可以负数:

mysql> select mod(-10,11);
+-------------+
| mod(-10,11) |
+-------------+
|         -10 |
+-------------+
1 row in set (0.00 sec)
​
mysql> select mod(-10,-11);
+--------------+
| mod(-10,-11) |
+--------------+
|          -10 |
+--------------+
1 row in set (0.00 sec)
​
mysql> select mod(10,-11);
+-------------+
| mod(10,-11) |
+-------------+
|          10 |
+-------------+
1 row in set (0.00 sec)

想要了解负数取模规则的可以自己去查一下,这里就不多说了。

其他函数

上面是mysql 常用的函数,但是还有一些其他类型的函数也经常使用。

database

该函数可以用于查看当前在哪一个数据库中

mysql> select database();
+------------+
| database() |
+------------+
| CURD       |
+------------+
1 row in set (0.00 sec)

ifnull

该函数的第一个参数如果为空,那么就返回第二个参数,如果不为空则返回第一个函数:

mysql> select ifnull(null, 1);
+-----------------+
| ifnull(null, 1) |
+-----------------+
|               1 |
+-----------------+
1 row in set (0.00 sec)
​
mysql> select ifnull(2, 1);
+--------------+
| ifnull(2, 1) |
+--------------+
|            2 |
+--------------+
1 row in set (0.01 sec)

md5

该函数用于加密,并且加密后是32位

mysql> select md5('12345678');
+----------------------------------+
| md5('12345678')                  |
+----------------------------------+
| 25d55ad283aa400af464c76d713c07ad |
+----------------------------------+
1 row in set (0.00 sec)
​
mysql> select md5('hello world');
+----------------------------------+
| md5('hello world')               |
+----------------------------------+
| 5eb63bbbe01eeed093cb22bb8f5acdc3 |
+----------------------------------+
1 row in set (0.00 sec)

其中如果有一个表如果是保存密码的就可以使用 md5 来加密,保存的密码就是加密后的内容。

password

password 也是用来加密的,但是加密比 md5 还要严格

mysql> select password('12345678');
+-------------------------------------------+
| password('12345678')                      |
+-------------------------------------------+
| *84AAC12F54AB666ECFC2A83C676908C8BBC381B1 |
+-------------------------------------------+
1 row in set, 1 warning (0.00 sec)
​
mysql> select password('hello world');
+-------------------------------------------+
| password('hello world')                   |
+-------------------------------------------+
| *67BECF85308ACF0261750DA1075681EE5C412F05 |
+-------------------------------------------+
1 row in set, 1 warning (0.00 sec)

其它类型的函数还有一些,想了解更多的可以下去自己查找~

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

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

相关文章

ES线程池设置

一文搞懂ES中的线程池 - 知乎 ES线程池设置-阿里云开发者社区 文章目录 一、简介 二、线程池类型 2.1、fixed 2.2、scaling 2.3、direct 2.4、fixed_auto_queue_size 三、处理器设置 四、查看线程池 4.1、cat thread pool 4.2、nodes info 4.3、nodes stats 4.4、no…

前端网络相关的面试题

get和post经过几次tcp连接? HTTP的GET和POST请求都是基于TCP协议的,因此在发送请求之前都需要建立TCP连接。TCP连接的建立通常被称为三次握手(Three-way Handshake)。 第一次握手:客户端发送一个SYN包(同步序列编号…

【python爬虫】8.温故而知新

文章目录 前言回顾前路代码实现体验代码功能拆解获取数据解析提取数据存储数据 程序实现与总结 前言 Hello又见面了!上一关我们学习了爬虫数据的存储,并成功将QQ音乐周杰伦歌曲信息的数据存储进了csv文件和excel文件。 学到这里,说明你已经…

nvm集合node版本,解决新版本jeecgboot3.5.3前端启动失败问题

jeecgboot前端3.5.3页面如下 使用之前的pnpm启动会报错,pnpm是node进行安装的,查询后发现,vue3版本的页面至少需要node16版本,我之前的版本只有15.5,适用于vue2 那么我将先前的node15.5版本删除,然后安装…

【Hadoop】DataNode 详解

🍁 博主 "开着拖拉机回家"带您 Go to New World.✨🍁 🦄 个人主页——🎐开着拖拉机回家_Linux,Java基础学习,大数据运维-CSDN博客 🎐✨🍁 🪁🍁 希望本文能够给您带来一定的…

Redis——》实现分布式锁

推荐链接: 总结——》【Java】 总结——》【Mysql】 总结——》【Redis】 总结——》【Kafka】 总结——》【Spring】 总结——》【SpringBoot】 总结——》【MyBatis、MyBatis-Plus】 总结——》【Linux】 总结——》【MongoD…

【解决】idea启动spring MVC报错:一个或多个listeners启动失败Listener ClassNotFoundException

idea配置教程。tomcat调试报错Artifact :war exploded: Error during artifact deployment。 修改代码后,启动不生效,仍是旧代码。 根本原因是: Modules output path和Artifacts output directory不匹配 Modules output path一定要等于Ar…

网络编程 day 5

1、根据select TCP服务器流程图编写服务器 #include <myhead.h>#define ERR_MSG(msg) do{\fprintf(stderr, "__%d__:", __LINE__); \perror(msg);\ }while(0)#define PORT 8888 //端口号&#xff0c;范围1024~49151 #define IP "192.168.…

Uniapp中vuex的使用

vuex的学习笔记&#xff0c;很多地方还都不是很懂&#xff0c;先记下来再说&#xff0c;比小程序里自带的store复杂很多&#xff0c;看着头大&#xff0c;而且方法里面很多ES6的内容&#xff0c;头都看到爆炸 一、初始化vuex 新建store.js&#xff0c;挂载到main.js 1、在根…

Flink SQL你用了吗?

分析&回答 Flink 1.1.0&#xff1a;第一次引入 SQL 模块&#xff0c;并且提供 TableAPI&#xff0c;当然&#xff0c;这时候的功能还非常有限。Flink 1.3.0&#xff1a;在 Streaming SQL 上支持了 Retractions&#xff0c;显著提高了 Streaming SQL 的易用性&#xff0c;使…

前端性能优化

前言 性能优化这个问题&#xff0c;在面试的过程中问道的概率还挺大的&#xff0c;特别是对有前端开发经验的面试者来说&#xff0c;基本会被面试官问道关于性能优化的问题。但是在我们做项目的过程中&#xff0c;可能业务比较简单&#xff0c;并没有复杂到需要专门去优化的程…

c#接口(interface)

概述&#xff1a; 在C#中&#xff0c;接口是一种定义了一组相关方法、属性和事件的规范。接口可以被类或结构体实现&#xff0c;以提供一种方式来定义类之间的契约或协议。 接口定义了一组成员&#xff0c;这些成员没有具体的实现。实现接口的类必须提供这些成员的具体实现。…

linuxdeploy安装CentOS7搭建django服务

目录 一、busybox安装 二、linuxdeploy安装 三、linuxdeploy软件设置及安装 四、CentOS基础环境配置 五、CentOS7 上安装Python3.8.10 六、systemctl的替代品 七、CentOS7 上安装mysql5.2.27数据库 八、CentOS7 上安装Nginx服务 九、Django项目应用部署 参考文献: 一…

《Python入门到精通》webbrowser模块详解,Python webbrowser标准库,Python浏览器控制工具

「作者主页」&#xff1a;士别三日wyx 「作者简介」&#xff1a;CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者 「推荐专栏」&#xff1a;小白零基础《Python入门到精通》 webbrowser模块详解 1、常用操作2、函数大全webbrowser.open() 打开浏览器webbro…

线程同步与互斥

目录 前言&#xff1a;基于多线程不安全并行抢票 一、线程互斥锁 mutex 1.1 加锁解锁处理多线程并发 1.2 如何看待锁 1.3 如何理解加锁解锁的本质 1.4 CRAII方格设计封装锁 前言&#xff1a;基于线程安全的不合理竞争资源 二、线程同步 1.1 线程同步处理抢票 1.2 如何…

Python爬虫(十七)_糗事百科案例

糗事百科实例 爬取糗事百科段子&#xff0c;假设页面的URL是: http://www.qiushibaike.com/8hr/page/1 要求&#xff1a; 使用requests获取页面信息&#xff0c;用XPath/re做数据提取获取每个帖子里的用户头像连接、用户姓名、段子内容、点赞次数和评论次数保存到json文件内…

实现不同局域网文件共享的解决方案:使用Python自带HTTP服务和端口映射

文章目录 1. 前言2. 本地文件服务器搭建2.1 python的安装和设置2.2 cpolar的安装和注册 3. 本地文件服务器的发布3.1 Cpolar云端设置3.2 Cpolar本地设置 4. 公网访问测试5. 结语 1. 前言 数据共享作为和连接作为互联网的基础应用&#xff0c;不仅在商业和办公场景有广泛的应用…

2023.8.26-2023.9.3 周报【3D+GAN+Diffusion基础知识+训练测试】

目录 学习目标 学习内容 学习时间 学习产出 学习目标 1. 3D方向的基础知识 2. 图像生成的基础知识&#xff08;GAN \ Diffusion&#xff09; 3. 训练测试GAN和Diffusion 学习内容 1. 斯坦福cv课程-3D &#xff08;网课含PPT&#xff09; 2. sjtu生成模型课件 3. ge…

TCP--半连接队列和全连接队列

原文地址&#xff1a;https://plantegg.github.io/2020/04/07/%E5%B0%B1%E6%98%AF%E8%A6%81%E4%BD%A0%E6%87%82TCP–%E5%8D%8A%E8%BF%9E%E6%8E%A5%E9%98%9F%E5%88%97%E5%92%8C%E5%85%A8%E8%BF%9E%E6%8E%A5%E9%98%9F%E5%88%97–%E9%98%BF%E9%87%8C%E6%8A%80%E6%9C%AF%E5%85%AC%E…

【OpenCL基础 · 一】因源

文章目录 前言一、单核标量处理器的瓶颈1.提升时钟频率2.提升指令级并行能力 二、多核和向量化1.多核2.向量化 三、异构并行和OpenCL1.GPGPU2.CUDA和OpenCL 前言 随着人工智能的发展以及大部分场景中实时性的要求&#xff0c;人们对于计算机算力要求逐渐增加。为了提高计算速度…