一些常用的 mysql 命令

TODO

  • 獲取各個庫使用存儲
select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;

+----------------------+--------------+
| table_schema         | MB           |
+----------------------+--------------+
| anta_channel         |  11.76562500 |
| anta_mw_order_prod   |   4.23437500 |
| cardts               |   5.18750000 |
| chaoxin              |   8.04687500 |
| cloudcode            |   0.14062500 |
| config-server-db     |   0.03125000 |
  • 建表時指定 auto increment 列初始值
CREATE TABLE `table1` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `value` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7
  • myql 只准許每個表有一個列 auto increment 且必須爲主鍵
    there can be only one auto column and it must be defined as a key
發佈了40 篇原創文章 · 獲贊 1 · 訪問量 3405
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章