Oracle的常用的命令

來源:互聯網
上載者:User

標籤:

  • --匯出資料庫
  • exp test2/[email protected] file=e:\test2.dmp owner=test2
  • --匯入資料庫
  • imp test2/[email protected] file=‘e:\test.dmp‘ fromuser=test touser=test2
  • --查看oracle當前的串連數
  • select * from v$session where username is not null
  • --查看不同使用者的串連數
  • select username,count(username) from v$session where username is not null group by username
  • --串連數
  • select count(*) from v$session
  • --並發串連數
  • Select count(*) from v$session where status=‘ACTIVE‘
  • --查看當前有哪些使用者正在使用資料 
  • 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;
  • --oracle 服務
  • OracleDBConsoleorcl --可以不啟動,用於管理Oracle的企業管理器的服務; 
  • OracleJobSchedulerORCL --通常不啟動,用於定期操作任務的服務; 
  • OracleOraDb10g_home1iSQL*Plus --可以不啟動,這是isqlplus服務,用於用網頁執行sql執行,11g已經取消了這個功能; 
  • OracleOraDb10g_home1TNSListener --必須啟動,這是監聽,用於遠程用戶端串連你的Oracle; 
  • OracleServiceORCL --必須啟動,這是Oracle資料庫的服務。 
  • 可以用命令啟動: 
  • #啟動listener:lsnrctl start 
  • #啟動資料庫:net start OracleServiceORCL 
  • --建立使用者
  • CREATE USER sa IDENTIFIED BY trp;
  • --授予DBA許可權
  • GRANT DBA to sa;
  • --授予建立串連許可權,否則使用者不能正常登陸
  • GRANT CREATE SESSION TO sa
  • --刪除使用者
  • DROP USER sa
  • --建立暫存資料表空間 
  • create temporary tablespace test_temp tempfile ‘E:\oracle\product\10.2.0\oradata\testserver\test_temp01.dbf‘ size 32m autoextend onnext 32m maxsize 2048m extent management local; 
  • --建立資料資料表空間 
  • create tablespace test_data logging datafile ‘E:\oracle\product\10.2.0\oradata\testserver\test_data01.dbf‘ size 32m autoextend on next 32m maxsize 2048m extent management local; 
  • --建立使用者並指定資料表空間 
  • create user testserver_user identified by testserver_user default tablespace test_data temporary tablespace test_temp; 
  • 資料匯出: 
  • 1 將資料庫TEST完全匯出,使用者名稱system 密碼manager 匯出到D:daochu.dmp中 
  •    exp system/[email protected] file=d:daochu.dmp full=y 
  • 2 將資料庫中system使用者與sys使用者的表匯出 
  •    exp system/[email protected] file=d:daochu.dmp owner=(system,sys) 
  • 3 將資料庫中的表inner_notify、notify_staff_relat匯出 
  •     exp aichannel/[email protected] file= d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat) 
  • 4 將資料庫中的表table1中的欄位filed1以"00"打頭的資料匯出 
  •    exp system/[email protected] file=d:daochu.dmp tables=(table1) query=" where filed1 like ‘00%‘" 
  • 資料的匯入 
  • 1 將D:daochu.dmp 中的資料匯入 TEST資料庫中。 
  •    imp system/[email protected] file=d:daochu.dmp 
  •    imp aichannel/[email protected] full=y file=d:datanewsmgnt.dmp ignore=y 
  •    上面可能有點問題,因為有的表已經存在,然後它就報錯,對該表就不進行匯入。 
  •    在後面加上 ignore=y 就可以了。 
  • 2 將d:daochu.dmp中的表table1 匯入 
  •    imp system/[email protected] file=d:daochu.dmp tables=(table1) 
  • 常見錯誤
  • 1.ORA-00257: 歸檔程式錯誤。在釋放之前僅限於內部串連【由於不斷歸檔導致磁碟空間,可調整歸檔空間大小,或刪除部分以前的歸檔】
  • 解決方案1:先手工刪除D:\oracle\product\10.2.0\flash_recovery_area裡面的日誌,然後使用者用rman(Recovory Manager)進入把歸檔日誌刪除
  • 1)rman登陸命令>rman target /
  • 2)命令>crosscheck archivelog all;
  • 3)命令>delete expired archivelog all;
  • 4)命令>exit
  • --刪除100天前日誌
  • delete NOPROMPT archivelog until time "sysdate-100";
  • 解決方案2:調整FLASH_RECOVERY_AREA的大小:
  • 登陸命令>sqlplus / as sysdba
  • 修改命令>alter system set db_recovery_file_dest_size=8G scope=both;
  • 查看命令>show parameter db_recovery_file_dest_size;
  • 關閉登陸>shutdown immediate;
  • 重啟>startup

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.