#历史操作记录
select t.SQL_TEXT, t.FIRST_LOAD_TIME from v$sqlarea t where t.FIRST_LOAD_TIME like '2020-10-11%' order by t.FIRST_LOAD_TIME desc;
#当前的连接数
select count(*) from v$process;
#数据库允许的最大连接数
select value from v$parameter where name = 'processes';
#自动扩展的表空间和非自动扩展的表空间查询(两者都是准确的)
SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024) "表空间大小(M)",
free / (1024 * 1024) "表空间剩余大小(M)",
(total - free) / (1024 * 1024) "表空间使用大小(M)",
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 tablespace_name,round(used_percent,4) used_percent from dba_tablespace_usage_metrics;
#查询表空间是否是自动扩展
select tablespace_name,autoextensible from dba_data_files;
#查询数据库中即将过期的账号
select username from dba_users where lock_date > trunc(sysdate - 7) or (account_status in ('EXPIRED(GRACE)') and (expiry_date between sysdate -7 and sysdate + 7)) or ((expiry_date between sysdate -7 and sysdate + 7) and account_status not in ('LOCKED'));
启动oracle:
启动监听: lsnrctl start LISTENER
启动数据库:
sqlplus / as sysdba
startup
#导出表结构:(表明,字段名,字段类型,字段描述)
select t.table_name,t.colUMN_NAME,t.DATA_TYPE || '(' || t.DATA_LENGTH || ')',t1.COMMENTS from User_tab_Cols t,User_Col_Comments t1 where t.table_name=t1.table_name and t.column_name = t1.column_name;
网友评论