oracle 查询表空间和描述 sql
时间: 2023-09-10 09:13:38 浏览: 39
要查询Oracle数据库中的表空间及其描述,您可以使用以下SQL查询:
```
SELECT tablespace_name, tablespace_type, contents, extent_management, status, logging
FROM dba_tablespaces;
```
其中,`tablespace_name`列将显示表空间的名称,`tablespace_type`列将显示表空间的类型,`contents`列将显示表空间的内容类型(例如,数据或索引),`extent_management`列将显示表空间的扩展管理类型(例如,本地或字典管理),`status`列将显示表空间的状态(例如,ONLINE或OFFLINE),`logging`列将显示表空间是否启用了日志记录。
如果您需要查询某个特定表空间的描述,可以使用以下SQL查询:
```
SELECT tablespace_name, description
FROM dba_tablespaces
WHERE tablespace_name = 'your_tablespace_name';
```
其中,`tablespace_name`列将显示表空间的名称,`description`列将显示表空间的描述。请注意,表空间的描述只在Oracle数据库版本10g及更高版本中可用。如果表空间没有描述,则该列将显示空值。
相关问题
oracle 查看表空间使用情况的sql
你可以使用以下 SQL 查询 Oracle 数据库中表空间的使用情况:
```sql
SELECT tablespace_name,
ROUND(SUM(bytes) / 1024 / 1024, 2) total_size_mb,
ROUND(SUM(bytes - NVL(free_space, 0)) / 1024 / 1024, 2) used_size_mb,
ROUND(NVL(SUM(free_space), 0) / 1024 / 1024, 2) free_size_mb,
ROUND((SUM(bytes - NVL(free_space, 0)) / SUM(bytes)) * 100, 2) pct_used
FROM (SELECT tablespace_name,
file_id,
SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name, file_id
UNION ALL
SELECT tablespace_name,
file_id,
SUM(bytes) bytes
FROM dba_temp_files
GROUP BY tablespace_name, file_id
UNION ALL
SELECT tablespace_name,
MIN(file_id) file_id,
SUM(bytes) bytes
FROM sys.v_$backup_datafile
GROUP BY tablespace_name)
LEFT OUTER JOIN (SELECT tablespace_name,
file_id,
SUM(bytes) free_space
FROM dba_free_space
GROUP BY tablespace_name, file_id) ON file_id = file_id AND tablespace_name = tablespace_name
GROUP BY tablespace_name
ORDER BY tablespace_name;
```
这个 SQL 查询语句将返回表空间名称、总大小、已使用大小、可用大小以及已使用百分比等信息。
ORACLE查看表占表空间的sql语句
要查看Oracle数据库中表占用的表空间,可以使用以下SQL语句:
```sql
SELECT
segment_name,
segment_type,
owner,
bytes/1024/1024 AS "Size(MB)",
tablespace_name
FROM
dba_segments
WHERE
segment_type = 'TABLE'
AND owner = 'your_owner_name'
AND segment_name = 'your_table_name';
```
请将`your_owner_name`替换为需要查询的表的所有者,`your_table_name`替换为需要查询的表名。执行该查询语句后,将返回该表所占用的表空间、表大小等信息。