SELECT table_name, data_length + index_length AS len, table_rows, CONCAT(STUFF((data_length + index_length)/1024/1024,2),'MB') AS datas FROM information_schema.tables WHERE table_schema = 'JZCIS' ORDER BY len DESC;
时间: 2024-04-14 19:26:04 浏览: 17
你提供的SQL查询语句用于获取指定数据库中表的大小信息,并按照大小降序排列。以下是你的查询语句:
```sql
SELECT table_name, data_length + index_length AS len, table_rows,
CONCAT(STUFF(CAST((data_length + index_length)/1024/1024 AS DECIMAL(10, 2)), 4, 0, 'MB')) AS datas
FROM information_schema.tables
WHERE table_schema = 'JZCIS'
ORDER BY len DESC;
```
这个查询使用了 `information_schema.tables` 表来获取指定数据库(`JZCIS`)中的表信息。它计算了每个表的数据长度和索引长度之和,并将结果转换为MB单位,保留两位小数。
注意,我在查询语句中添加了 `CAST` 函数来将计算结果转换为 `DECIMAL(10, 2)` 类型,以便保留两位小数。然后,使用 `STUFF` 函数将结果中的第4个字符位置插入 'MB',以形成带有单位的字符串。
请确保将 `'JZCIS'` 替换为你实际的数据库名称。
希望这次能够帮到你。如果还有其他问题,请随时提问。
相关问题
group_concat(table_name)
As an AI language model, I can tell you that the "group_concat(table_name)" function is used in SQL to concatenate multiple rows of a column into a single string. The function takes one parameter, which is the name of the table column to be concatenated.
For example, if you have a table named "employees" and a column named "name", and you want to concatenate all the names into a single string, you can use the following SQL query:
SELECT GROUP_CONCAT(name) FROM employees;
This will return a single row with a comma-separated string of all the names in the "name" column of the "employees" table.
使用的是alter table table_name add rows 之类的
在Hive中,使用`ALTER TABLE`语句来添加新的行是不支持的。`ALTER TABLE`语句主要用于修改表结构,例如添加、删除或重命名列,更改列类型等。如果你想要向表中插入新的行,你可以使用`INSERT INTO`语句。以下是示例:
```
INSERT INTO table_name
VALUES (value1, value2, value3, ...);
```
请将`table_name`替换为要插入数据的表名,然后将`value1, value2, value3, ...`替换为要插入的实际值。确保值的顺序与表中的列顺序相匹配。