태그 보관물: mysql

mysql

MySQL에있는 테이블 수를 계산하는 쿼리 있으며 때로는

나는 가지고있는 테이블 수를 늘리고 있으며 때로는 데이터베이스의 테이블 수를 계산하기 위해 빠른 명령 줄 쿼리를 수행하는 것이 궁금합니다. 가능합니까? 그렇다면 어떤 쿼리입니까?



답변

SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'dbName';

출처

이 내 꺼야:

USE databasename;
SHOW TABLES;
SELECT FOUND_ROWS();


답변

모든 데이터베이스와 요약을 계산하려면 다음을 시도하십시오.

SELECT IFNULL(table_schema,'Total') "Database",TableCount
FROM (SELECT COUNT(1) TableCount,table_schema
      FROM information_schema.tables
      WHERE table_schema NOT IN ('information_schema','mysql')
      GROUP BY table_schema WITH ROLLUP) A;

다음은 샘플 실행입니다.

mysql> SELECT IFNULL(table_schema,'Total') "Database",TableCount
    -> FROM (SELECT COUNT(1) TableCount,table_schema
    ->       FROM information_schema.tables
    ->       WHERE table_schema NOT IN ('information_schema','mysql')
    ->       GROUP BY table_schema WITH ROLLUP) A;
+--------------------+------------+
| Database           | TableCount |
+--------------------+------------+
| performance_schema |         17 |
| Total              |         17 |
+--------------------+------------+
2 rows in set (0.29 sec)

시도 해봐 !!!


답변

SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'dbo' and TABLE_TYPE='BASE TABLE'


답변

이것은 당신에게 mysql에있는 모든 데이터베이스의 이름과 테이블 수를 줄 것이다.

SELECT TABLE_SCHEMA,COUNT(*) FROM information_schema.tables group by TABLE_SCHEMA;


답변

테이블 수를 계산하려면 다음을 수행하십시오.

USE your_db_name;    -- set database
SHOW TABLES;         -- tables lists
SELECT FOUND_ROWS(); -- number of tables

때로는 쉬운 일이 일을 할 것입니다.


답변

SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'database_name';


답변

데이터베이스의 테이블을 계산하는 여러 가지 방법이있을 수 있습니다. 내가 가장 좋아하는 것은 다음과 같습니다.

SELECT
    COUNT(*)
FROM
    `information_schema`.`tables`
WHERE
    `table_schema` = 'my_database_name'
;