oracle 常用指令碼

來源:互聯網
上載者:User

標籤:select   datafile   資料庫   product   rac   data   users   sele   不同   

/*//查詢oracle的串連數select count(*) from v$session;//目前使用者串連數 select count(*) from v$session t where t.username=‘WIMS‘ ;//資料庫允許的最大串連數select value from v$parameter where name = ‘processes‘//修改最大串連數:alter system set processes = 300 scope = spfile;  2、查詢oracle的並發串連數select count(*) from v$session where status=‘ACTIVE‘;3、查看不同使用者的串連數select username,count(username) from v$session where username is not null group by username;4、查看所有使用者:select * from all_users;5、查看使用者或角色系統許可權(直接賦值給使用者或角色的系統許可權):select * from dba_sys_privs;select * from user_sys_privs;6、查看角色(只能查看登陸使用者擁有的角色)所包含的許可權select * from role_sys_privs;7、查看使用者物件許可權:select * from dba_tab_privs;select * from all_tab_privs;select * from user_tab_privs;8、查看所有角色:select * from dba_roles;9、查看使用者或角色所擁有的角色:select * from dba_role_privs;select * from user_role_privs;10、查看哪些使用者有sysdba或sysoper系統許可權(查詢時需要相應許可權)select * from V$PWFILE_USERS;  重啟資料庫:shutdown immediate;startup;--查看當前有哪些使用者正在使用資料SELECT osuser, a.username,cpu_time/executions/1000000||‘s‘, sql_fulltext,machinefrom v$session a, v$sqlarea bwhere 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;--1、查看錶在那個資料表空間  select tablespace_name,table_name from user_talbes where table_name=‘employ‘;--2、擷取使用者的預設資料表空間  select   username,   DEFAULT_TABLESPACE     from   dba_users where username=‘scott‘;--3、查看錶空間所有的檔案    select * from dba_data_files where tablespace_name=‘USERS‘;--4、查看錶空間使用方式:    SELECT tbs 資料表空間名,                                        sum(totalM) 總共大小M,                                        sum(usedM) 已使用空間M,                                        sum(remainedM) 剩餘空間M,                                        sum(usedM)/sum(totalM)*100 已使用百分比,                                sum(remainedM)/sum(totalM)*100 剩餘百分比                                FROM(                                                 SELECT b.file_id ID,                                         b.tablespace_name tbs,                                         b.file_name name,                                         b.bytes/1024/1024 totalM,                                         (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 usedM,                             sum(nvl(a.bytes,0)/1024/1024) remainedM,                                 sum(nvl(a.bytes,0)/(b.bytes)*100),                                     (100 - (sum(nvl(a.bytes,0))/(b.bytes)*100))                                 FROM dba_free_space a,dba_data_files b                                 WHERE a.file_id = b.file_id                                     GROUP BY b.tablespace_name,b.file_name,b.file_id,b.bytes                         ORDER BY b.tablespace_name                                    )                                                GROUP BY tbs                                                                                        --5、擴充資料表空間   alter database datafile ‘D:\Oracle\PRODUCT\ORADATA\TEST\USERS01.DBF‘ resize 50m;  --自動成長    alter database datafile ‘D:\oracle\PRODUCT\ORADATA\TEST\USERS01.DBF‘ autoextend on next 50m maxsize 500m;      --增加資料檔案   alter tablespace yourtablespacename add datafile ‘d:\newtablespacefile.dbf‘ size 5m;            */

 

oracle 常用指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.