全面解析MySQL(2)——CRUD基礎

1.Create

Create(創建):添加新數據到數據庫中

#基礎語法
insert into table_name (column1,column2,column3, ...) 
values (value1,value2,value3, ...);

1.1 單行全列插入

value中值的數量和順序必須和column?致

describe demo1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int         | YES  |     | NULL    |       |
| name  | varchar(20) | YES  |     | NULL    |       |
| age   | int         | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
#插入(id=1,name='張三',age=10)的記錄
mysql> insert into demo1 values (1,'張三',10);
Query OK, 1 row affected (0.01 sec)
#插入結果如下
mysql> select * from demo1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | 張三 |   10 |
+------+------+------+
1 row in set (0.00 sec)

1.2 單行指定列插入

demo1:指定(id,name,age)三列插入,相當于全列插入

insert into demo1 (id,name,age) values (2,'李四',11);
Query OK, 1 row affected (0.00 sec)mysql> select * from demo1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | 張三 |   10 |
|    2 | 李四 |   11 |
+------+------+------+
2 rows in set (0.00 sec)

demo2:指定(id,name)兩列插入

insert into demo1 (id,name) values (3,'王五');
Query OK, 1 row affected (0.00 sec)mysql> select * from demo1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | 張三 |   10 |
|    2 | 李四 |   11 |
|    3 | 王五 | NULL |
+------+------+------+
3 rows in set (0.00 sec)

1.3 多行插入

在?條insert語句中也可以一次插入多行數據

insert into demo1 values (4,'趙六',12),(5,'田七',13);
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0mysql> select * from demo1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | 張三 |   10 |
|    2 | 李四 |   11 |
|    3 | 王五 | NULL |
|    4 | 趙六 |   12 |
|    5 | 田七 |   13 |
+------+------+------+
5 rows in set (0.00 sec)

2.Read

Read(讀取):查詢或獲取現有數據

#基礎語法
select 通配符/列名 from 表名

2.1 全列查詢

#(*)通配符
#使?(*)可以查詢表中(所有列)的值
select * from demo1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | 張三 |   10 |
|    2 | 李四 |   11 |
|    3 | 王五 | NULL |
|    4 | 趙六 |   12 |
|    5 | 田七 |   13 |
+------+------+------+
5 rows in set (0.00 sec)

2.1 指定列查詢

指定(id,name)兩列查詢

select id,name from demo1;
+------+------+
| id   | name |
+------+------+
|    1 | 張三 |
|    2 | 李四 |
|    3 | 王五 |
|    4 | 趙六 |
|    5 | 田七 |
+------+------+
5 rows in set (0.00 sec)
#注意1:可以指定多列查詢,也可以指定單列查詢
#注意2:查詢的順序和指定的順序有關
select name,id from demo1;
+------+------+
| name | id   |
+------+------+
| 張三 |    1 |
| 李四 |    2 |
| 王五 |    3 |
| 趙六 |    4 |
| 田七 |    5 |
+------+------+
5 rows in set (0.00 sec)

2.3 表達式作為查詢條件

select * from exam;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
+------+--------+---------+------+---------+
7 rows in set (0.00 sec)
#將表達式(english + 10)作為查詢條件
mysql> select id,name,chinese,math,(english+10) from exam;
+------+--------+---------+------+--------------+
| id   | name   | chinese | math | (english+10) |
+------+--------+---------+------+--------------+
|    1 | 唐三藏 |      67 |   98 |           66 |
|    2 | 孫悟空 |      87 |   78 |           87 |
|    3 | 豬悟能 |      88 |   98 |          100 |
|    4 | 曹孟德 |      82 |   84 |           77 |
|    5 | 劉玄德 |      55 |   85 |           55 |
|    6 | 孫權   |      70 |   73 |           88 |
|    7 | 宋公明 |      75 |   65 |           40 |
+------+--------+---------+------+--------------+
7 rows in set (0.00 sec)

2.4 為查詢結果指定別名

關鍵字:as

#為(chinese+math+english)指定別名為(總分)
select id,name,(chinese+math+english) as '總分' from exam;
+------+--------+------+
| id   | name   | 總分 |
+------+--------+------+
|    1 | 唐三藏 |  221 |
|    2 | 孫悟空 |  242 |
|    3 | 豬悟能 |  276 |
|    4 | 曹孟德 |  233 |
|    5 | 劉玄德 |  185 |
|    6 | 孫權   |  221 |
|    7 | 宋公明 |  170 |
+------+--------+------+
7 rows in set (0.00 sec)

2.5 去重查詢

關鍵字:distinct

2.5.1 去重查詢(單列)

select * from exam;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
|    8 | 關云長 |      70 |   80 |      90 |
+------+--------+---------+------+---------+
8 rows in set (0.00 sec)mysql> select english from exam;
+---------+
| english |
+---------+
|      56 |
|      77 |
|      90 |#第一個90分
|      67 |
|      45 |
|      78 |
|      30 |
|      90 |#第二個90分
+---------+
8 rows in set (0.00 sec)
#對(english)這一列進行去重
mysql> select distinct english from exam;
+---------+
| english |
+---------+
|      56 |
|      77 |
|      90 |#第一個90分
|      67 |
|      45 |
|      78 |
|      30 |
+---------+
7 rows in set (0.00 sec)

注意:在這里插入圖片描述

2.5.2 去重查詢(多列)

select * from exam;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
+------+--------+---------+------+---------+
9 rows in set (0.00 sec)mysql> select math,english from exam;
+------+---------+
| math | english |
+------+---------+
|   98 |      56 |
|   78 |      77 |
|   98 |      90 |
|   84 |      67 |
|   85 |      45 |
|   73 |      78 |
|   65 |      30 |
|   80 |      90 |#(1)math=80,english=90
|   80 |      90 |#(2)math=80,english=90
+------+---------+
9 rows in set (0.00 sec)
#同時對(math,english)兩列同時進行去重查詢
#要保證兩行中math和english的分數要分別相同
mysql> select distinct math,english from exam;
+------+---------+
| math | english |
+------+---------+
|   98 |      56 |
|   78 |      77 |
|   98 |      90 |
|   84 |      67 |
|   85 |      45 |
|   73 |      78 |
|   65 |      30 |
|   80 |      90 |
+------+---------+
8 rows in set (0.00 sec)

注意:
在這里插入圖片描述

2.6 條件查詢

關鍵字:where

#基礎語法
select 通配符/列名 from 表名 where (條件)

2.6.1 比較運算符

運算符說明
>,<,>=,<=大于,小于,大于等于,小于等于
=等于(MySQL中不存在==)
<=>用于null的比較。例如:null <=> null 的結果是true,null = null 的結果還是null
!=,<>不等于
value between A and B范圍匹配,如果value在[A,B]之間返回true
value not between A and B范圍匹配,如果(value < A并且 value > B)返回true
value in (option1,option2…)如果value與某一option匹配則返回true,not in表示取反
is null/is not null是null/不是null
_模糊匹配,表示(一個)任意字符
like模糊匹配,表示(任意個)任意字符

2.6.2 邏輯運算符

運算符說明
and邏輯與,全true為true,有false為false
or邏輯或,全false為false,有true為true
not邏輯非,條件為true,結果為false

2.6.3 比較條件查詢

demo1:查詢語文成績比數學高的記錄

select * from exam where chinese > math;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    2 | 孫悟空 |      87 |   78 |      77 |
|    7 | 宋公明 |      75 |   65 |      30 |
+------+--------+---------+------+---------+
2 rows in set (0.01 sec)

demo2:查詢英語大于60的記錄

select * from exam where english > 60;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    6 | 孫權   |      70 |   73 |      78 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
+------+--------+---------+------+---------+
6 rows in set (0.00 sec)

demo3:查詢總分大于200的記錄

select id,name,(chinese + math + english) as '總分' from exam where (chinese + math + english) > 200;
+------+--------+------+
| id   | name   | 總分 |
+------+--------+------+
|    1 | 唐三藏 |  221 |
|    2 | 孫悟空 |  242 |
|    3 | 豬悟能 |  276 |
|    4 | 曹孟德 |  233 |
|    6 | 孫權   |  221 |
|    8 | 關云長 |  240 |
|    8 | 張翼德 |  240 |
+------+--------+------+
7 rows in set (0.00 sec)

注意:不能在where條件中進行取別名的操作在這里插入圖片描述

2.6.4 邏輯條件查詢

demo1:查詢語文成績大于80分并且數學成績大于80分的同學

select * from exam where chinese > 80 and math > 80;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
+------+--------+---------+------+---------+
2 rows in set (0.00 sec)

demo2:查詢語文成績大于80或者數學成績大于80分的同學

select * from exam where chinese > 80 or math > 80;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
+------+--------+---------+------+---------+
5 rows in set (0.00 sec)

注意:and的優先級大于or在這里插入圖片描述

2.6.5 范圍查詢

demo1:查詢語文成績在[80,90]分的記錄

select * from exam where chinese between 80 and 90;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
+------+--------+---------+------+---------+
3 rows in set (0.00 sec)

demo2:查詢數學成績是78或者79或者98或者99分的記錄

#使用or實現
select * from exam where math = 78 or math = 79 or math = 98 or math = 99;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
+------+--------+---------+------+---------+
3 rows in set (0.00 sec)
#使用in實現
mysql> select * from exam where math in (78,79,98,99);
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
+------+--------+---------+------+---------+
3 rows in set (0.00 sec)

2.6.6 模糊查詢

demo1:查詢姓孫的記錄

select * from exam where name like '孫%';
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    2 | 孫悟空 |      87 |   78 |      77 |
|    6 | 孫權   |      70 |   73 |      78 |
+------+--------+---------+------+---------+
2 rows in set (0.00 sec)

demo2:查詢姓孫并且名字只有兩個字的記錄

select * from exam where name like '孫_';
+------+------+---------+------+---------+
| id   | name | chinese | math | english |
+------+------+---------+------+---------+
|    6 | 孫權 |      70 |   73 |      78 |
+------+------+---------+------+---------+
1 row in set (0.00 sec)

2.6.7 null(空)值查詢

demo1:查詢英語成績為null的記錄

select * from exam where english is null;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|   11 | 黃漢升 |      70 |   85 |    NULL |
+------+--------+---------+------+---------+
1 row in set (0.00 sec)mysql> select * from exam where english <=> null;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|   11 | 黃漢升 |      70 |   85 |    NULL |
+------+--------+---------+------+---------+
1 row in set (0.00 sec)

demo2:查詢英語成績不為null的記錄

select * from exam where english != null;
Empty set (0.00 sec)mysql> select * from exam where english <> null;
Empty set (0.00 sec)mysql> select * from exam where english is not null;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
|   10 | 趙子龍 |      70 |   85 |      85 |
+------+--------+---------+------+---------+
10 rows in set (0.00 sec)

2.7 排序

  • asc:升序
  • desc:降序,不是查看表結構的desc(describe)
#基礎語法
#默認asc
select 通配符/列名 from 表名 (where...) order by 列名 (asc/desc);

demo1:按照語文成績升序

select * from exam order by chinese asc;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    5 | 劉玄德 |      55 |   85 |      45 |
|    1 | 唐三藏 |      67 |   98 |      56 |
|    6 | 孫權   |      70 |   73 |      78 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
|   10 | 趙子龍 |      70 |   85 |      85 |
|   11 | 黃漢升 |      70 |   85 |    NULL |
|    7 | 宋公明 |      75 |   65 |      30 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
+------+--------+---------+------+---------+
11 rows in set (0.00 sec)

demo2:按照語文成績降序

select * from exam order by chinese desc;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    3 | 豬悟能 |      88 |   98 |      90 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    7 | 宋公明 |      75 |   65 |      30 |
|    6 | 孫權   |      70 |   73 |      78 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
|   10 | 趙子龍 |      70 |   85 |      85 |
|   11 | 黃漢升 |      70 |   85 |    NULL |
|    1 | 唐三藏 |      67 |   98 |      56 |
|    5 | 劉玄德 |      55 |   85 |      45 |
+------+--------+---------+------+---------+
11 rows in set (0.00 sec)

demo3:按照數學降序,英語升序,語?升序

select * from exam order by math desc,english asc,chinese asc;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|   11 | 黃漢升 |      70 |   85 |    NULL |
|    5 | 劉玄德 |      55 |   85 |      45 |
|   10 | 趙子龍 |      70 |   85 |      85 |
|    4 | 曹孟德 |      82 |   84 |      67 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
+------+--------+---------+------+---------+
11 rows in set (0.00 sec)

2.8 分頁查詢

#基礎語法1:默認從0開始,篩選num條記錄
select 通配符/列名 from 表名 (where...) (order by ...) limit num;
#基礎語法2:從start開始,篩選num條記錄
select 通配符/列名 from 表名 (where...) (order by ...) limit start,num;
#基礎語法3(建議):從start開始,篩選num條記錄
select 通配符/列名 from 表名 (where...) (order by ...) limit num offset start;

demo1:假設一頁有三條記錄,查詢第一頁的記錄

#建議搭配(order by)使用
select * from exam order by id asc limit 3 offset 0;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   78 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
+------+--------+---------+------+---------+
3 rows in set (0.00 sec)

demo2:假設一頁有三條記錄,查詢第二頁的記錄

select * from exam order by id asc limit 3 offset 3;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    4 | 曹孟德 |      82 |   84 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
+------+--------+---------+------+---------+
3 rows in set (0.00 sec)

3.Update

Update(更新):修改數據庫或系統中已存在的記錄

#基礎語法
update 表名 (要修改的數據) (where...) (order by...) (limit...);

demo1:將孫悟空的數學成績變更為80分

update exam set math = 80 where name = '孫悟空';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from exam where name = '孫悟空';
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    2 | 孫悟空 |      87 |   80 |      77 |
+------+--------+---------+------+---------+
1 row in set (0.00 sec)

demo2:將曹孟德的數學成績變更為60分,語文成績變更為70

update exam set math = 60,chinese = 70 where name = '曹孟德';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from exam where name = '曹孟德';
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    4 | 曹孟德 |      70 |   60 |      67 |
+------+--------+---------+------+---------+
1 row in set (0.00 sec)

注意:當update語句缺少where條件時,全表的記錄都將被更新

4.Delete

Delete(刪除):從數據庫或系統中移除記錄

#基礎語法
delete from 表名 (where...) (order by...) (limit...);

demo1:刪除姓名為黃漢升的記錄

delete from exam where name = '黃漢升';
Query OK, 1 row affected (0.01 sec)mysql> select * from exam;
+------+--------+---------+------+---------+
| id   | name   | chinese | math | english |
+------+--------+---------+------+---------+
|    1 | 唐三藏 |      67 |   98 |      56 |
|    2 | 孫悟空 |      87 |   80 |      77 |
|    3 | 豬悟能 |      88 |   98 |      90 |
|    4 | 曹孟德 |      70 |   60 |      67 |
|    5 | 劉玄德 |      55 |   85 |      45 |
|    6 | 孫權   |      70 |   73 |      78 |
|    7 | 宋公明 |      75 |   65 |      30 |
|    8 | 關云長 |      70 |   80 |      90 |
|    8 | 張翼德 |      70 |   80 |      90 |
|   10 | 趙子龍 |      70 |   85 |      85 |
+------+--------+---------+------+---------+
10 rows in set (0.00 sec)

demo2:刪除整張表的記錄

delete from exam;
Query OK, 10 rows affected (0.01 sec)mysql> select * from exam;
Empty set (0.00 sec)

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/89848.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/89848.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/89848.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

某外企筆試總結——純C語言

這里寫自定義目錄標題一、sizeof 計算&#xff08;32位環境&#xff09;二、簡答題三、數據存儲區域與可修改性四、字符串比較輸出及原因五、數組指針運算輸出六、字符串倒序代碼錯誤排查七、下面程序可以把1維數組轉為2維數組&#xff0c;然后調用 printArr2D 打印出數組內容&…

Qt Graphs 模塊擬取代 charts 和 data visualization還有很長的路要走

近期關注 Qt 6.10 的分支進展&#xff0c; 發現了 Qt 6.10 的 charts 和 data visualization &#xff08;以下簡稱 DV&#xff09;已經被deprecated, 功能將會合并到 graphs 模塊。如果后面 charts\ DV 被棄用&#xff0c;那算是很大的API變化了。從Qt 6.5 以后開始引入的 gra…

2025牛客暑期多校訓練營2(部分補題)

題目鏈接&#xff1a;牛客競賽_ACM/NOI/CSP/CCPC/ICPC算法編程高難度練習賽_牛客競賽OJ B Bitwise Perfect 思路 考慮到由&#xff0c;那么只有變小的時候對答案的貢獻才能夠減少&#xff0c;從二進制的角度考慮什么時候變小&#xff0c;只有min(x,y)中的最高位1異或之后變…

Nginx的location匹配規則

Nginx的location匹配規則 為什么你的Nginx配置總是不生效&#xff1f; 改了Nginx配置無數次&#xff0c;reload命令執行了幾十遍&#xff0c;瀏覽器訪問時卻依然返回404&#xff1f;運維工程師小張上周就遇到了這個問題&#xff1a;明明配置了location /static/ { root /var/ww…

USB 2.0 vs USB 3.0:全面技術對比與選擇指南

USB 2.0 vs USB 3.0&#xff1a;全面技術對比與選擇指南 引言 在當今數字時代&#xff0c;USB接口已成為連接設備與計算機的最普遍標準之一。從2000年USB 2.0的發布到2008年USB 3.0的問世&#xff0c;USB技術經歷了顯著的演進。本文將深入比較這兩種廣泛使用的USB標準&#xff…

DApp架構設計與開發流程指南

目錄 DApp架構設計與開發流程指南 引言:DApp的核心特性 一、DApp架構設計 1.1 分層架構設計 各層核心組件: 1.2 典型架構模式 1.2.1 全去中心化架構 1.2.2 混合架構(推薦) 二、開發流程 2.1 敏捷開發流程 2.2 詳細開發階段 階段1:需求分析與設計(1-2周) 階段2:智能合約…

Windows下odbc配置連接SQL Server

一、查看SQL Server服務是否啟動打開SQL Server 2022配置管理器查看SQL Server運行狀態&#xff0c;可以設置 啟動或停止服務二、windows下如何配置ODBC數據源1、Windows搜索欄中輸入“ODBC數據源管理器”并選擇“以管理員身份運行”來打開它2、添加新的數據源ODBC數據源管理器…

MySQL—表設計和聚合函數以及正則表達式

文章目錄一、第一范式&#xff08;原子性&#xff09;二、第二范式&#xff08;消除部分依賴&#xff09;三、第三范式&#xff08;消除傳遞依賴&#xff09;四、表設計五、聚合函數六、正則表達式MySQL 的三大范式&#xff08;1NF、2NF、3NF&#xff09;是關系型數據庫設計的核…

基于Electron打包jar成Windows應用程序

基于Electron打包jar成Windows應用程序簡介注意編譯及命令&#xff1a;運行效果登錄界面用戶管理界面界面全屏鎖屏界面文檔查看界面簡介 本文介紹了一種將maven jar包打包成Windows下EXE可執行程序的方法。 Maven打包Java Web應用成jar&#xff0c;Electron封裝jar成Windows …

Autosar RTE實現觀測量生成-基于ETAS軟件

文章目錄前言觀測量定義arTypedPerInstanceMemoryPorts Measurable工具鏈配置及使用Port中的配置arTypedPerInstanceMemory觀測量生成文件分析總結前言 之前我們在XCP中&#xff0c;對于標定量和觀測量并沒有嚴格按照Autosar標準中定義&#xff0c;Autosar RTE中對標定量和觀測…

【REACT18.x】creat-react-app在添加eslint時報錯Environment key “jest/globals“ is unknown

今天在創建新項目的時候&#xff0c;給cra創建的項目添加eslint支持&#xff0c;出現如下報錯 添加eslint npx eslint --init頁面報錯 Compiled with problems:ERROR [eslint] package.json eslint-config-react-app/jest#overrides[0]:Environment key "jest/globals&…

Linux的例行性工作 -- (練習)

1、atd和crond兩個任務管理程序的區別 答&#xff1a; atd 專為一次性任務設計&#xff0c;允許用戶在特定未來時間點&#xff08;絕對或相對時間&#xff09;執行單次命令后就結束。 crond 則是周期性任務的調度核心&#xff0c;通過配置文件&#xff08;crontab&#xff09;實…

《Java語言程序設計》1.6 復習題

1.6.1 什么是Java語言規范?計算機有嚴格的使用規則。如果編寫程序時沒有遵循這些規則&#xff0c;計算機就不能理解程序。Java語言規范和Java API定義了Java的標準。Java語言規范(Java language specification)是對Java程序設計語言的語法和語義的技術定義。應用程序接口(Appl…

【機器學習深度學習】什么是量化?

目錄 前言 一、量化的基本概念 1.1 量化對比示例 1.2 量化是如何實現的&#xff1f; 二、為什么要進行量化&#xff1f; 2.1 解決模型體積過大問題 2.2 降低對算力的依賴 2.3 加速模型訓練和推理 2.4 優化訓練過程 2.5 降低部署成本 小結&#xff1a;量化的應用場…

告別 T+1!解密金融級實時數據平臺的構建與實踐

在數字金融浪潮下&#xff0c;數據處理的“實時性”已不再是加分項&#xff0c;而是逐漸成為決定業務價值的核心競爭力。然而&#xff0c;金融機構在追求實時的道路上&#xff0c;往往陷入一個新的困境&#xff1a;實時分析系統與離線大數據平臺形成了兩套獨立的“煙囪”&#…

[Python] -項目實戰7- 用Python和Tkinter做一個圖形界面小游戲

一、為什么從小游戲入門GUI? 趣味性強:小游戲直觀、有趣,一學就上手。 系統掌握事件驅動:了解按鈕點擊、鍵盤響應、圖形刷新機制。 扎實基礎:為日后構建更復雜應用奠定 GUI 編程基礎。 二、選定游戲:猜數字小游戲 ?? 這個小游戲界面簡單,核心機制是:3 個按鈕分別…

【18】MFC入門到精通——MFC(VS2019)+ OpenCV 顯示圖片的3種方法

MFC (VS2019)+ OpenCV,顯示圖片的3種方法 1 方法介紹 2 方法一:嵌套OpenCV窗口顯示圖片 2.1 建立供工程 添加控件 2.2 引用頭文件 2.3 找到OnInitDialog()函數,在其中添加如下代碼 2.4 在button觸發函數中加入代碼(就是你雙擊button進入的函數) 2.5 注意事項 3 方法二:…

以“融合進化 智領未來”之名,金倉Kingbase FlySync:國產數據庫技術的突破與創新

目錄開篇&#xff1a;國產數據庫的歷史性跨越一、KFS 產品定位及發展歷程回顧1.1 Kingbase FlySync 發展1.2 Kingbase FlySync與Oracle GoldenGate的對比分析1.2.1 Kingbase FlySync 功能優勢1.2.2 技術架構對比1.2.3 性能與擴展性二、數字化時代的新挑戰2.1 決策實時性要求越來…

服務器配置錯誤漏洞

文章目錄一、文件解析漏洞1.Apache HTTPD多后綴解析漏洞二、目錄遍歷漏洞1.Apache目錄遍歷漏洞2.Nginx目錄穿越漏洞服務器配置錯誤漏洞指因服務器&#xff08;含系統、Web服務、數據庫等&#xff09;的參數設置、權限分配、組件配置等不當&#xff0c;導致的安全問題&#xff0…

大模型預測輸尿管上段結石技術方案大綱

目錄 1. 術前階段 2. 術中階段 3. 術后階段 4. 并發癥風險預測 5. 根據預測定手術方案 6. 麻醉方案 7. 術后護理 8. 統計分析 9. 技術驗證方法 10. 實驗證據 11. 健康教育與指導 12. 完整術方案流程圖(Mermaid) 1. 術前階段 步驟 關鍵要素 可編輯字段 1.1 影像采集 CT-IVU / …