您好,登錄后才能下訂單哦!
instance_name,service_name參數將實例和服務動態注冊到listerer中。
1、CMD
2、LSNRCTL運行至LSNRCTL端
3、LSNRCTL>status 查看狀態
4、LSNRCTL>stop 監聽停止
5、LSNRCTL>start 啟動監聽
6、LSNRCTL>reload 重新啟動
=========================================
sqlplus / as sysdba; 超級用戶(sysdba)
sqlplus system/admin as sysdba;
sqlplus scott/tiger@orcl;
Sqlplus /nolog; 進入sql模式
conn / as sysdba; 以DBA身份連接數據庫
create user unary identified by 123; 創建unary用戶,密碼:123
alter user system identified by unary123; //修改帳號的密碼
grant dba,sysdba to unary; 給與unary用戶DBA權限
GRANT SELECT ON SCOTT.EMP TO unary; //把EMP這個表所有權給unary,用戶賦予表查詢權限
select distinct owner from all_objects; 查看當前系統用戶
select username from dba_users; 查看當前所有用戶
SQL> conn sys(用戶名)/manager(密碼)@orcl(實例名)as sysdba; 連接數據庫
SQL> conn system/2008Bc1223@orcl as sysdba;
4、RMAN登錄(鼠標右鍵CMD.EXE以“管理員方式登錄”不加分號)
Rman>rman target sys/2008Bc1223@orcl
=========================================================================
1、sqlplus system/123@orcl as sysdba //管理員身份連接數據庫
2、SQL> archive log list; //查看當前歸檔模式,是歸檔還是非歸檔
3、SQL> shutdown immediate; //關閉數據庫
4、SQL> startup mount; //啟動數據庫到mount狀態
5、SQL> alter database archivelog/noarchivelog; //啟動/關閉自動歸檔模式
6、SQL>Alter system archive log current; //切換當前日志并且自動歸檔
7、SQL> alter database open; //啟動數據庫,打開數據庫并將其裝入
8、SQL> Select status from v$instance; //查看數據庫是否打開-open
注意:Select instance_name from v$instance; //查看oracle數據庫名字,即SID_NAME = ORCL
==================================================
SQL>show parameter db_name; //查看oracle數據庫名稱命令 orcl
SQL>select status from v$instance; //查看oracle當前數據庫的狀態 open
SQL>show parameter db_recover; //查看oracle查看閃回恢復區的信息(默認:歸檔日志會存放到閃回恢復區)
SQL>select name from v$datafile; //查詢數據庫DBF文件位置
SQL>select open_mode from v$database; //查詢數據庫狀態,打開和可寫模式 open/write
SQL>select file#,name,status,enabled,checkpoint_change# from v$datafile; //查詢數據文件狀態
SQL>select sum(bytes)/1024/1024/1024 as GB from v$datafile; //查詢數據文件(表空間)大小
SQL>select sum(bytes)/1024/1024/1024 as GB from dba_segments; //查詢有效數據大小
SQL>select * from v$version; //查詢數據庫版本信息
SQL>select instance_name from v$instance; //查詢當前數據庫實例名稱
SQL>select * from global_name; //查詢全局數據庫名稱
SQL>select name from v$datafile; //查詢數據文件位置
==================================================
SQL>show parameter db_recover; //查看oracle數據庫閃回區的路徑及容量
SQL>alter system set db_recovery_file_dest_size=50G; // 更改歸檔目錄容量目標為50G,默認4G
SQL>alter system set log_archive_dest_1='location=c:\archivelog'; //變更歸檔路徑,重啟數據庫生效。alter database open;
SQL>alter system archive log current; //手動產生歸檔日志
SQL>alter system switch logfile; 切換歸檔方式日志組;和以下命令結合使用。
SQL>alter system set log_archive_format='ARC%S_%R.%T_%D.log' scope=spfile; 生成歸檔日志文件
===================================================
如果可以登錄任意的一個用戶可以通過一下方法來知道當前有哪些用戶
SQL>select distinct owner from all_objects 查看當前用戶
oracle數據庫新建表命令:
SQL>sql>create table unary(ItemNO number(2),ItemName varchar2(20)); 創建 unary表格
SQL>sql>drop table unary 刪除unary 刪除表命令
SQL> select TABLE_NAME from all_tables; 查看當前庫的所有數據表
===================================================
數據文件重定位
1. 脫機 Alter database datafile 'c:\oracle\data02.dbf' offline;
2. 復制 Host copy c:\oracle\data02.dbf c:\oracle\oradata\ora10\data02.dbf
3. 修改控制文件中的文件名 Alter database rename file c:\oracle\data02.dbf to c:\oracle\oradata\ora10\data02.dbf
4. 同步文件頭部與數據庫 Recover datafile 'c:\oracle\oradata\ora10\data02.dbf'
5. 把它重新聯機,以便可供使用 Alter database datafile 'c:\oracle\oradata\ora10\data02.dbf' online;
===================================================
1、RMAN登錄(鼠標右鍵CMD.EXE以“管理員方式登錄”不加分號)
Rman>rman target sys/2008Bc1223@orcl
或:cmd:> Rman target / nocatalog
delete obsolete;//刪除備份集
Crosscheck backup //校驗備份集
計劃任務:
開始-輸入“計劃”,右擊“microsoft”
C:\Users\Administrator>rman target sys/2008Bc1223@orcl cmdfile='D:\app\full.sql' log='D:\app\full.log'
--------------------------------------------------------------------------------------
RMAN> change archivelog all crosscheck; //當數據庫無法備份時,交叉檢測,保證備份集有效
RMAN> delete expired archivelog all; //當數據庫無法備份時,刪除過期日志expired(過期的)
--------------------------------------------------------------------------------------
===================================================
如果ORACLE無法啟動,可能是數據庫恢復沒有完成,操作如下:
RMAN> recover database;
RMAN> alter database open resetlogs;//重新打開數據庫
數據庫已打開
SQL> select open_mode from v$database;
===================================================
完全備份數據庫指定路徑:
RMAN> backup incremental level 0 database format 'c:\bakup\database-%s-%T-%t-%U.
bak';
===================================================
//RMAN中執行,《查看備份集信息和刪除過期與失效得備份集》
RMAN>List incarnation; //查看生命周期
RMAN>list backup; //查看備份集信息
RMAN>report obsolete; //列出過期的備份集
RMAN>delete noprompt obsolete; //刪除過期的備份集
RMAN>crosscheck backup; //驗證備份集有效性
RMAN>delete expired backup; //刪除失效的備份集
#RMAN恢復到指定時間點
run{
set until time "to_date('2017-01-14 21:10:00','yyyy-mm-dd hh34:mi:ss')";
restore database;
recover database;
}
alter database open resetlogs;
對備份對象進行完全備份
每次備份的數據只是相對于上一次備份后新增加的和修改過的數據
每次備份的數據是相對于上一次全備份之后增加的和修改過的數據
自上次備份以來對數據庫所做的改變。
run{
allocate channel ch2 device type disk;
backup incremental level 0 database format 'D:\app\Administrator\BACKUP\database-%s-%T-%t-%U-%d.bak';
sql 'alter system archive log current'; \\
backup archivelog all format 'D:\app\Administrator\BACKUP\archlog-%s-%T-%t-%U-.bak' delete all input;
backup current controlfile format 'D:\app\Administrator\BACKUP\ctrlfile-%s-%T-%t-%U-.bak'; \\備份控制文件命令
release channel ch2; \\釋放通道
report obsolete;
delete noprompt obsolete;
crosscheck backup;
delete noprompt expired backup;
}
run{
allocate channel ch2 device type disk;
backup incremental level 1 database format 'D:\app\Administrator\BACKUP\database-%s-%T-%t-%U-.bak';
sql 'alter system archive log current';
backup archivelog all format 'D:\app\Administrator\BACKUP\archlog-%s-%T-%t-%U-%d.bak' delete all input;
backup current controlfile format 'D:\app\Administrator\BACKUP\ctrlfile-%s-%T-%t-%U-%d.bak';
release channel ch2;
}
run{
allocate channel ch2 device type disk;
backup incremental level 1 cumulative database format 'D:\app\Administrator\BACKUP\database-%s-%T-%t-%U-%d.bak';
sql 'alter system archive log current';
backup archivelog all format 'D:\app\Administrator\BACKUP\archlog-%s-%T-%t-%U-%d.bak' delete all input;
backup current controlfile format 'D:\app\Administrator\BACKUP\ctrlfile-%s-%T-%t-%U-%d.bak';
release channel ch2;
}
run{
allocate channel ch2 device type disk;
sql 'alter system archive log current';
Backup archivelog from time "to_date('2017-01-14 18:07:00', 'yyyy-mm-dd hh34:mi:ss')"
format 'D:\app\Administrator\BACKUP\archlog-%s-%T-%t-%U-%d.bak' delete all input;
backup current controlfile format 'D:\app\Administrator\BACKUP\ctrlfile-%s-%T-%t-%U-%d.bak';
release channel ch2;
}
1、CMD> sqlplus sys/sys@orcl as sysdba
2、SQL> archive log list;
3、SQL> shutdown immediate; 關閉數據庫
4、SQL> startup mount; 啟動數據庫到mount狀態
5、SQL> alter database archivelog;啟動歸檔模式
6、SQL> alter database open; 啟動數據庫
1、SQL> shutdown immediate; 2、SQL> startup mount;
3、SQL> alter database noarchivelog; 4、SQL> alter database open;
1、啟動實例、加載數據庫、打開數據庫。 STARTUP [nomount | mount | open ]
2、關閉數據庫、卸載數據庫、關閉Oracle實例。SHUTDOWN [normal | transactional | immediate ]
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。