mysql 查詢系統 mysql一些系統查詢sql

2021-10-22 04:42:20 字數 998 閱讀 7101

一、好言

別把最好的時光,浪費在無謂的等待與猶豫不決中。

二、背景

記錄下有關sql查詢mysql系統變數等資訊。

三、mysql一些系統查詢

檢視索引

show index from db.table

檢視資料路連線數:

show status like 'threads%';

show global status like 'thread%';

系統設定最大連線數:

show variables like '%max_connections%';

顯示資料庫表資訊:

show table status from db like table;

某一張表資訊:

show table status from db like table

檢視表資訊:

select table_schema, table_name, table_comment from

information_schema.tables where engine like 'innodb'

select table_schema, table_name, data_free/1024/1024 as

data_free_mb from

information_schema.tables where engine like 'innodb' and

data_free > 100*1024*1024;

說明:data_free該字段是代表空間碎片的大小。

顯示每張表的每個字段

select * from information_schema.columns

匯入資料

load data infile '/tmp/user-pwd.txt' into table.t_user_pwd fields terminated by ',' enclosed by '"' lines terminated by '\r\n';

Mysql 系統變數查詢

原文 mysql系統變數包括全域性變數 global 和會話變數 session global變數對所有session生效,session變數包括global變數。mysql調優必然會涉及這些系統變數的調整,所以我們首先得會查詢系統變數。1 查詢全域性變數 show global variables...

MYsql 查詢資料 一

一 簡單查詢 select from 表名 表示查詢 這個表裡的所有資料。select 欄位1,欄位2 from 表名 表示查詢這個表裡的字段1,2 select distinct 欄位1,欄位2,欄位3 from 表名 distinct關鍵字避免重複資料查詢 二 實現數學四則運算查詢 select...

mysql高階查詢(一)

修改表 修改表名 alter table 舊表名 rename to 新錶名 新增字段 alter table 表名 add 欄位名 資料型別 屬性 修改字段 alter table 表名 change 原欄位名 新欄位名 資料型別 屬性 刪除字段 alter table 表名 drop 欄位名 新...