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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。