1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| -- create
CREATE TABLE EMPLOYEE (
empId INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL
);
-- insert
INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales');
INSERT INTO EMPLOYEE VALUES (0002, 'Dave', 'Accounting');
INSERT INTO EMPLOYEE VALUES (0003, 'Ava', 'Sales');
SELECT table_schema "Database Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) "Database Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
|
1
2
3
4
5
| +------------------+---------------------+
| Database Name | Database Size in MB |
+------------------+---------------------+
| test_db | 0.02 |
+------------------+---------------------+
|