oracle 禁用索引
同步數據的時候 有索引會比較慢 可以暫時禁用索引
--禁用索引
ALTER INDEX PK_T_AUTH_USERROLE_ID UNUSABLE;--恢復索引
ALTER INDEX UK_T_AUTH_USER_EMP_CODE REBUILD;
--查看索引狀態
select status from user_indexes where index_name=‘UK_T_AUTH_USER_EMP_CODE‘;
11、查詢oracle的連接數
2select count(*) from v$session;
32、查詢oracle的並發連接數
4select count(*) from v$session where status=‘ACTIVE‘;
5
6select username,count(username) from v$session where username is not null group by username;
74、查看所有用戶:
8select * from all_users;
95、查看用戶或角色系統權限(直接賦值給用戶或角色的系統權限):
10select * from dba_sys_privs;
11select * from user_sys_privs;
126、查看角色(只能查看登陸用戶擁有的角色)所包含的權限
13select * from role_sys_privs;
147、查看用戶對象權限:
15
16select * from all_tab_privs;
17select * from user_tab_privs;
188、查看所有角色:
19select * from dba_roles;
209、查看用戶或角色所擁有的角色:
21select * from dba_role_privs;
22select * from user_role_privs;
2310、查看哪些用戶有sysdba或sysoper系統權限(查詢時需要相應權限)
24select * from V$PWFILE_USERS;
select count(*) from v$process --當前的連接數
select value from v$parameter where name = ‘processes‘ --數據庫允許的最大連接數
修改最大連接數:
alter system set processes = 300 scope = spfile;
重啟數據庫:
shutdown immediate;
startup;
--查看當前有哪些用戶正在使用數據
SELECT osuser, a.username,cpu_time/executions/1000000||‘s‘, sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;
select count(*) from v$session #連接數
select count(*) from v$session where status=‘ACTIVE‘ #並發連接數
show parameter processes #最大連接
alter system set processes = value scope = spfile;重啟數據庫 #修改連接
SQL> Select count(*) from v$session where status=‘ACTIVE‘ ;
COUNT(*)
----------
20
SQL> Select count(*) from v$session;
COUNT(*)
----------
187
SQL> show parameter processes;
NAME TYPE VALUE
------------------------------------ ----------- ----------
aq_tm_processes integer 0
db_writer_processes integer 1
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 450
SQL>
並發指active,I SEE
SQL> select count(*) from v$session #連接數
SQL> Select count(*) from v$session where status=‘ACTIVE‘ #並發連接數
SQL> show parameter processes #最大連接
SQL> alter system set processes = value scope = spfile;重啟數據庫 #修改連接
unix 1個用戶session 對應一個操作系統 process
而 windows體現在線程
DBA要定時對數據庫的連接情況進行檢查,看與數據庫建立的會話數目是不是正常,如果建立了過多的連接,會消耗數據庫的資源。同時,對一些“掛死”的連接,可能會需要DBA手工進行清理。
以下的SQL語句列出當前數據庫建立的會話情況:
select sid,serial#,username,program,machine,status
from v$session;
輸出結果為:
SID SERIAL# USERNAME PROGRAM MACHINE STATUS
---- ------- ---------- ----------- --------------- --------
1 1 ORACLE.EXE WORK3 ACTIVE
2 1 ORACLE.EXE WORK3 ACTIVE
3 1 ORACLE.EXE WORK3 ACTIVE
4 1 ORACLE.EXE WORK3 ACTIVE
5 3 ORACLE.EXE WORK3 ACTIVE
6 1 ORACLE.EXE WORK3 ACTIVE
7 1 ORACLE.EXE WORK3 ACTIVE
8 27 SYS SQLPLUS.EXE WORKGROUP\\WORK3 ACTIVE
11 5 DBSNMP dbsnmp.exe WORKGROUP\\WORK3 INACTIVE
其中,
SID 會話(session)的ID號;
SERIAL# 會話的序列號,和SID一起用來唯一標識一個會話;
USERNAME 建立該會話的用戶名;
PROGRAM 這個會話是用什麽工具連接到數據庫的;
STATUS 當前這個會話的狀態,ACTIVE表示會話正在執行某些任務,INACTIVE表示當前會話沒有執行任何操作;
如果DBA要手工斷開某個會話,則執行:
alter system kill session \‘SID,SERIAL#\‘
SELECT username, machine, program, status, COUNT (machine) AS
連接數量
FROM v$session
GROUP BY username, machine, program, status
ORDER BY machine;
顯示結果(每個人的機器上會不同)
SCHNEIDER|WORKGROUD\WANGZHENG|TOAD.exe|ACTIVE|1
SCHNEIDER|WORKGROUP\597728AA514F49D|sqlplusw.exe|INACTIVE|1
|WWW-Q6ZMR2OIU9V|ORACLE.EXE|ACTIVE|8
PUBLIC|||INACTIVE|0 按主機名查詢 SELECT COUNT(*) FROM V$SESSION WHERE MACHINE = ‘DXMH‘; ‘DXMH‘為主機名 數據恢復語句 create table informationlaw_bak
as
select * from informationlaw as of TIMESTAMP to_timestamp(‘20121126 103435‘,‘yyyymmdd hh24miss‘); //按機器名分組查 select username,machine,count(username) from v$session where username is not null group by username,machine;
oracle 禁用索引