zoukankan      html  css  js  c++  java
  • mysql查看某张表、库的大小

    1、查询某张表的大小

    mysql >  select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables where table_schema='test' AND table_name='t9'; 

    2、查看某个数据库表的数据

    [root@tst-yangsq2-2 ~]# mysqlshow -uroot -p --count test
    Enter password: 
    Database: test
    +--------+----------+------------+
    | Tables | Columns  | Total Rows |
    +--------+----------+------------+
    | t1     |        1 |          2 |
    | t2     |        1 |          2 |
    | t3     |        2 |          1 |
    | t4     |        1 |          6 |
    | t5     |        1 |          1 |
    | t6     |        1 |         14 |
    | t7     |        1 |          0 |
    | t8     |        1 |         12 |
    | t9     |        7 |      48147 |
    +--------+----------+------------+

    3、查询某个数据库某张表的数据 #类似于desc

    [root@tst-yangsq2-2 ~]# mysqlshow -uroot -p --count test t9
    Enter password: 
    Database: test  Table: t9  Rows: 48147
    +--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
    | Field        | Type                 | Collation | Null | Key | Default           | Extra                       | Privileges                      | Comment |
    +--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
    | payment_id   | smallint(5) unsigned |           | NO   |     |                   |                             | select,insert,update,references |         |
    | customer_id  | smallint(5) unsigned |           | NO   | MUL |                   |                             | select,insert,update,references |         |
    | staff_id     | tinyint(3) unsigned  |           | NO   | MUL |                   |                             | select,insert,update,references |         |
    | rental_id    | int(11)              |           | YES  | MUL |                   |                             | select,insert,update,references |         |
    | amount       | decimal(5,2)         |           | NO   |     |                   |                             | select,insert,update,references |         |
    | payment_date | datetime             |           | NO   |     |                   |                             | select,insert,update,references |         |
    | last_update  | timestamp            |           | YES  |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | select,insert,update,references |         |
    +--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
     
     
  • 相关阅读:
    mysql 初始密码 设置
    jsp基础知识(基本的语法及原理)
    hdu 2473 Junk-Mail Filter (并查集之点的删除)
    java版本的学生管理系统
    java操作数据库出现(][SQLServer 2000 Driver for JDBC]Error establishing socket.)的问题所在即解决办法
    Java学习之约瑟夫环的两中处理方法
    hdu 3367(Pseudoforest ) (最大生成树)
    hdu 1561 The more, The Better (树上背包)
    Nginx + Lua 搭建网站WAF防火墙
    长连接和短连接
  • 原文地址:https://www.cnblogs.com/Knight7971/p/9963299.html
Copyright © 2011-2022 走看看