一. 修改自增長字段值
- 自增長起始值修改只能比原來更大,不能更小
- alter table testid auto_increment=100;
二. 事務
1. 隔離級別
查看事務隔離級別:show variables like 'transaction_isolation';
默認值:('transaction_isolation', 'REPEATABLE-READ');
三. 數據統計
1. 數據庫表信息
select
table_schema as '數據庫',
table_name as '表名',
table_rows as '記錄數',
truncate(data_length/1024/1024, 2) as '數據容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)',
AUTO_INCREMENT as '自增長初始值',
ENGINE,
UPDATE_TIME,
TABLE_COMMENT
from information_schema.tables
where table_schema='庫名'
order by table_rows desc, index_length desc;
SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='庫名';
- table_schema: 記錄數據庫名
- table_name: 記錄數據表名
- engine : 存儲引擎
- table_rows: 關於表的粗略行估計
- data_length : 記錄表的大小(單位字節)
- index_length : 記錄表的索引的大小
- row_format: 可以查看數據表是否壓縮過
2. 列信息
SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '數據庫名'
ORDER BY TABLE_NAME DESC ;
3. 索引信息
SELECT * FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = '數據庫名' and table_name='表名'
ORDER BY INDEX_NAME DESC,SEQ_IN_INDEX ;
4. 事務
- 執行時間超過1秒的事務語句
select * from information_schema.innodb_trx where TIME_TO_SEC(timediff(now(),trx_started)) > 1