oracle常用命令
阿新 • • 發佈:2020-11-17
--Oracle查看錶空間大小(單位不是GB)
SELECT
a.tablespace_name, --表空間名
total, --表空間大小
free, --表空間剩餘大小
(total-free), --表空間使用大小
Round((total-free)/total,4)*100 --使用率
FROM (SELECT tablespace_name,Sum(bytes) free
FROM DBA_FREE_SPACE
GROUP BY tablespace_name) a,
(SELECT tablespace_name,Sum(bytes) total
FROM DBA_DATA_FILES
GROUP BY tablespace_name)b
a.tablespace_name=b.tablespace_name;
--Oracle查看錶空間當前使用者
select username,default_tablespace
from user_users;
--Oracle查看錶所屬表空間
SELECT TABLE_NAME,TABLESPACE_NAME
FROM USER_TABLES
WHERE TABLE_NAME='test_table';
--Oracle查看錶空間大小-單位GB
SELECT
a.tablespace_name,
total,
free,
(total-free),
total/(1024*1024*1024),
free/(1024*1024*1024),
round((total-free)/total,4)*100
FROM (SELECT tablespace_name,SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name)a,
(SELECT tablespace_name,SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name)b
WHERE a.tablespace_name=b.tablespace_name;
--檢視資料庫表空間名稱
select file_name, tablespace_name ,bytes from dba_data_files;
點選這裡 | 點選這裡 | 點選這裡 | 點選這裡 |
---|---|---|---|
FILE_NAME | TABLESPACE_NAME | BYTES | |
1 | /oracledata/orcl/users01.dbf | USERS | 82575360 |
2 | /oracledata/orcl/sysaux01.dbf | SYSAUX | 429916160 |
3 | /oracledata/orcl/undot2.dbf | UNDOTV2 | 1761607680 |
4 | /oracledata/orcl/system01.dbf | SYSTEM | 597688320 |
5 | /oracledata/orcl/emsc01.dbf | EMSC | 629145600 |
6 | /oracledata/orcl/seal01.dbf | SEAL | 524288000 |
9 | /oracledata/orcl/E:ORACLEORADATAORCLhnsap.dbf | HNSAPSPACE1 | 1153433600 |
--檢視資料庫所有的表名稱和每張表所對應的資料條數
select t.table_name ,t.num_rows from user_tables t;
點選這裡 | 點選這裡 | 點選這裡 |
---|---|---|
TABLE_NAME | NUM_ROWS | |
1 | CLIENT_SOFT_UPDATE_RECORD | 278 |
2 | MDENCE_STAMP | 0 |
3 | TD_P_ROLE | 0 |
4 | TD_X_STAFF | 5 |
5 | PORC_EXECUTE_RECORD | 2185 |
6 | CLIENT_GROUP_BINDING | 79 |
7 | CLIENT_SOFT_UPDATE | 19 |
8 | AUDIT_DAY_AMOUNT | 22 |
9 | AUDIT_DAY_BWS_DETAIL | 97 |
10 | AUDIT_HELLY_DAY | 0 |
11 | AUDIT_HELLY_DETAIL | 0 |
12 | AUDIT_RULE | 3496 |
13 | AUDIT_RULE_ORG | 874 |
14 | ID_CARD_INFO | 417 |
15 | BILL_USER_CHECK_INFO | 4268 |
17 | BUSINESS_DICT | 0 |
18 | BUSINESS_INFO | 946 |