mysql我的常用命令
程序员文章站
2024-03-11 17:37:43
...
1. 查看
1.1 查看uuid
select @@server_uuid;
+--------------------------------------+
| @@server_uuid |
+--------------------------------------+
| ea5085ce-ac82-11ea-9dcd-005056b25447 |
+--------------------------------------+
1 row in set (0.00 sec)
1.2 查看binlog事件
show binlog events;
+---------------------------------+-----+----------------+------------+-------------+---------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+---------------------------------+-----+----------------+------------+-------------+---------------------------------------+
| 161cc2f8_fKGvn001-binlog.000001 | 4 | Format_desc | 3232235526 | 123 | Server ver: 5.7.22-log, Binlog ver: 4 |
| 161cc2f8_fKGvn001-binlog.000001 | 123 | Previous_gtids | 3232235526 | 154 | |
+---------------------------------+-----+----------------+------------+-------------+---------------------------------------+
2 rows in set (0.01 sec)
1.3 查看binlog日志
mysql> show binary logs;
±--------------------------------±----------+
| Log_name | File_size |
±--------------------------------±----------+
| 161cc2f8_fKGvn001-binlog.000001 | 154 |
±--------------------------------±----------+
1 row in set (0.00 sec)
1.4 flush
flush;
help flush;
flush slow logs;
flush local slow logs;
flush binary logs;
flush local binary logs;
flush privileges;
flush local privileges;
2 查询
2.1 查询在A表不在B表的数据
假设有A、B两张表。
如果查询在A表中存在,但是在B表中不存在的记录,应该如何操作?
A表
id |
---|
1 |
2 |
3 |
4 |
5 |
B表
id | a_id |
---|---|
1 | 3 |
2.1.1 子查询方法
select A.* from A where A.id not in(select B.a_id from B);
2.1.2 使用join方法
select * from A left join B on A.id = B.a_id;
下一篇: docker:常用命令汇总