最后用以下查询计算了GB表中MySQL表的大小.
SELECT(data_length + index_length)/ power(1024,3)tablesize_gb FROM information_schema.tables WHERE table_schema ='db'和table_name ='tablename'
是否有可能以GB为单位获取MySQL行的大小.
或者如何以GB为单位获取表的平均行大小.
解释起来有点困难,所以我会举个例子来解释,
假设我有这样的表(标签是 json 列)
+----+-------------------+--------------------+
| id | occupation | tags |
+----+-------------------+--------------------+
| 1 | Mold Maker | [Men, Shop, Shoes] |
| 2 | Software Engineer | [Men, Lifestyle] |
| 3 | Electrician | [Shop, Lifestyle] |
| 4 | Software Engineer | [Men, Lifestyle] |
| 5 | Software Engineer | [Shoes] |
+----+-------------------+--------------------+
Run Code Online (Sandbox Code Playgroud)
当我想获得职业的独特价值时,我只需这样查询即可。
SELECT DISTINCT occupation FROM customers;
或者
SELECT occupation FROM customers GROUP BY occupation;
result
+-------------------+
| occupation |
+-------------------+
| Mold …Run Code Online (Sandbox Code Playgroud)