notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Métadonnées bases et fichiers.sql

31 lines
910 B
MySQL
Raw Normal View History

2020-11-26 17:38:25 +00:00
-- m<>tadonn<6E>es des bases et fichiers de toute sles bases
SELECT *
FROM sys.databases;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
type_desc,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files
GROUP BY type_desc
ORDER BY type_desc;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
db.name,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files AS mf
JOIN sys.databases AS db
ON mf.database_id = db.database_id
GROUP BY db.name
ORDER BY SIZE_GB DESC;
SELECT SUM(size) * 8 / SQUARE(1024) AS SIZE_GB,
db.name, type_desc,
SUM(SUM(size) * 8 / SQUARE(1024)) OVER() AS TOTAL_SIZE_GB
FROM sys.master_files AS mf
JOIN sys.databases AS db
ON mf.database_id = db.database_id
GROUP BY db.name, type_desc
ORDER BY type_desc, SIZE_GB DESC;