阅读:4740回复:12
典藏之作: oracle 常用命令大汇总
第一章:日志管理
<P> 1.forcing log switches <P> sql> alter system switch logfile; <P> 2.forcing checkpoints <P> sql> alter system checkpoint; <P> 3.adding online redo log groups <P> sql> alter database add logfile [group 4] <P> sql> ('/disk3/log4a.rdo','/disk4/log4b.rdo') size 1m; <P> 4.adding online redo log members <P> sql> alter database add logfile member <P> sql> '/disk3/log1b.rdo' to group 1, <P> sql> '/disk4/log2b.rdo' to group 2; <P> 5.changes the name of the online redo logfile <P> sql> alter database rename file 'c:/oracle/oradata/oradb/redo01.log' <P> sql> to 'c:/oracle/oradata/redo01.log'; <P> 6.drop online redo log groups <P> sql> alter database drop logfile group 3; <P> 7.drop online redo log members <P> sql> alter database drop logfile member 'c:/oracle/oradata/redo01.log'; <P> 8.clearing online redo log files <P> sql> alter database clear [unarchived] logfile 'c:/oracle/log2a.rdo'; <P> 9.using logminer analyzing redo logfiles <P> a. in the init.ora specify utl_file_dir = ' ' <P> b. sql> execute dbms_logmnr_d.build('oradb.ora','c:\oracle\oradb\log'); <P> c. sql> execute dbms_logmnr_add_logfile('c:\oracle\oradata\oradb\redo01.log', <P> sql> dbms_logmnr.new); <P> d. sql> execute dbms_logmnr.add_logfile('c:\oracle\oradata\oradb\redo02.log', <P> sql> dbms_logmnr.addfile); <P> e. sql> execute dbms_logmnr.start_logmnr(dictfilename=>'c:\oracle\oradb\log\oradb.ora'); <P> f. sql> select * from v$logmnr_contents(v$logmnr_dictionary,v$logmnr_parameters <P> sql> v$logmnr_logs); <P> g. sql> execute dbms_logmnr.end_logmnr;</P> [此贴子已经被作者于2005-1-19 21:19:18编辑过]
|
|
|
1楼#
发布于:2005-01-19 21:25
>copy c:\backup\user.dbf c:\oradata\user.dbf (alter tablespace offline) <P> >recover datafile 'c:\oradata\user.dbf' or <P> >recover tablespace user_data; <P> >alter database datafile 'c:\oradata\user.dbf' online or <P> >alter tablespace user_data online; <P> --method 3(opened database,initially closed not system or rollback datafile) <P> >startup mount <P> >alter database datafile 'c:\oradata\user.dbf' offline; <P> >alter database open <P> >copy c:\backup\user.dbf d:\oradata\user.dbf <P> >alter database rename file 'c:\oradata\user.dbf'to 'd:\oradata\user.dbf' <P> >recover datafile 'e:\oradata\user.dbf' or recover tablespace user_data; <P> >alter tablespace user_data online; <P> --method 4(loss of data file with no backup and have all archive log) <P> >alter tablespace user_data offline immediate; <P> >alter database create datafile 'd:\oradata\user.dbf'as 'c:\oradata\user.dbf'' <P> >recover tablespace user_data; <P> >alter tablespace user_data online <P> 5.perform an open database backup <P> > alter tablespace user_data begin backup; <P> > copy files /backup/ <P> > alter database datafile '/c:/../data.dbf' end backup; <P> > alter system switch logfile; <P> 6.backup a control file <P> > alter database backup controlfile to 'control1.bkp'; <P> > alter database backup controlfile to trace; <P> 7.recovery (noarchivelog mode) <P> > shutdown abort <P> > cp files <P> > startup <P> 8.recovery of file in backup mode <P> >alter database datafile 2 end backup; <P> 9.clearing redo log file <P> >alter database clear unarchived logfile group 1; <P> >alter database clear unarchived logfile group 1 unrecoverable datafile; <P> 10.redo log recovery <P> >alter database add logfile group 3 'c:\oradata\redo03.log'size 1000k; <P> >alter database drop logfile group 1; <P> >alter database open; <P> or >cp c:\oradata\redo02.log' c:\oradata\redo01.log <P> >alter database clear logfile 'c:\oradata\log01.log';</P>
|
|
|
2楼#
发布于:2005-01-19 21:25
第十二章: BACKUP and RECOVERY <P> 1. v$sga,v$instance,v$process,v$bgprocess,v$database,v$datafile,v$sgastat <P> 2. Rman need set dbwr_IO_slaves or backup_tape_IO_slaves and large_pool_size <P> 3. Monitoring Parallel Rollback <P> > v$fast_start_servers , v$fast_start_transactions <P> 4.perform a closed database backup (noarchivelog) <P> > shutdown immediate <P> > cp files /backup/ <P> > startup <P> 5.restore to a different location <P> > connect system/manager as sysdba <P> > startup mount <P> > alter database rename file '/disk1/../user.dbf'to '/disk2/../user.dbf'; <P> > alter database open; <P> 6.recover syntax <P> --recover a mounted database <P> >recover database; <P> >recover datafile '/disk1/data/df2.dbf'; <P> >alter database recover database; <P> --recover an opened database <P> >recover tablespace user_data; <P> >recover datafile 2; <P> >alter database recover datafile 2; <P> 7.how to apply redo log files automatically <P> >set autorecovery on <P> >recover automatic datafile 4; <P> 8.complete recovery: <P> --method 1(mounted databae) <P> >copy c:\backup\user.dbf c:\oradata\user.dbf <P> >startup mount <P> >recover datafile 'c:\oradata\user.dbf; <P> >alter database open; <P> --method 2(opened database,initially opened,not system or rollback datafile) </P>
|
|
|
3楼#
发布于:2005-01-19 21:24
第十一章: manager role <P> 1.create roles <P> sql> create role sales_clerk; <P> sql> create role hr_clerk identified by bonus; <P> sql> create role hr_manager identified externally; <P> 2.modify role <P> sql> alter role sales_clerk identified by commission; <P> sql> alter role hr_clerk identified externally; <P> sql> alter role hr_manager not identified; <P> 3.assigning roles <P> sql> grant sales_clerk to scott; <P> sql> grant hr_clerk to hr_manager; <P> sql> grant hr_manager to scott with admin option; <P> 4.establish default role <P> sql> alter user scott default role hr_clerk,sales_clerk; <P> sql> alter user scott default role all; <P> sql> alter user scott default role all except hr_clerk; <P> sql> alter user scott default role none; <P> 5.enable and disable roles <P> sql> set role hr_clerk; <P> sql> set role sales_clerk identified by commission; <P> sql> set role all except sales_clerk; <P> sql> set role none; <P> 6.remove role from user <P> sql> revoke sales_clerk from scott; <P> sql> revoke hr_manager from public; <P> 7.remove role <P> sql> drop role hr_manager; <P> 8.display role information <P> view: =>dba_roles,dba_role_privs,role_role_privs,dba_sys_privs,
role_sys_privs,role_tab_privs,session_roles </P> |
|
|
4楼#
发布于:2005-01-19 21:24
第十章:managing privileges <P> 1.system privileges: view => system_privilege_map ,dba_sys_privs,session_privs <P> 2.grant system privilege <P> sql> grant create session,create table to managers; <P> sql> grant create session to scott with admin option; <P> with admin option can grant or revoke privilege from any user or role; <P> 3.sysdba and sysoper privileges: <P> sysoper: startup,shutdown,alter database open|mount,alter database backup controlfile, <P> alter tablespace begin/end backup,recover database <P> alter database archivelog,restricted session <P> sysdba: sysoper privileges with admin option,create database,recover database until <P> 4.password file members: view:=> v$pwfile_users <P> 5.O7_dictionary_accessibility =true restriction access to view or tables in other schema <P> 6.revoke system privilege <P> sql> revoke create table from karen; <P> sql> revoke create session from scott; <P> 7.grant object privilege <P> sql> grant execute on dbms_pipe to public; <P> sql> grant update(first_name,salary) on employee to karen with grant option; <P> 8.display object privilege : view => dba_tab_privs, dba_col_privs <P> 9.revoke object privilege <P> sql> revoke execute on dbms_pipe from scott [cascade constraints]; <P> 10.audit record view :=> sys.aud$ <P> 11. protecting the audit trail <P> sql> audit delete on sys.aud$ by access; <P> 12.statement auditing <P> sql> audit user; <P> 13.privilege auditing <P> sql> audit select any table by summit by access; <P> 14.schema object auditing <P> sql> audit lock on summit.employee by access whenever successful; <P> 15.view audit option : view=> all_def_audit_opts,dba_stmt_audit_opts,dba_priv_audit_opts,
dba_obj_audit_opts <P> 16.view audit result: view=> dba_audit_trail,dba_audit_exists,dba_audit_object, dba_audit_session,dba_audit_statement </P> |
|
|
5楼#
发布于:2005-01-19 21:23
第九章:Managing users <P> 1.create a user: database authentication <P> sql> create user juncky identified by oracle default tablespace users <P> sql> temporary tablespace temp quota 10m on data password expire <P> sql> [account lock|unlock] [profile profilename|default]; <P> 2.change user quota on tablespace <P> sql> alter user juncky quota 0 on users; <P> 3.drop a user <P> sql> drop user juncky [cascade]; <P> 4. monitor user <P> view: dba_users , dba_ts_quotas</P>
|
|
|
6楼#
发布于:2005-01-19 21:23
第八章: managing password security and resources <P> 1.controlling account lock and password <P> sql> alter user juncky identified by oracle account unlock; <P> 2.user_provided password function <P> sql> function_name(userid in varchar2(30),password in varchar2(30), <P> old_password in varchar2(30)) return boolean <P> 3.create a profile : password setting <P> sql> create profile grace_5 limit failed_login_attempts 3 <P> sql> password_lock_time unlimited password_life_time 30 <P> sql>password_reuse_time 30 password_verify_function verify_function <P> sql> password_grace_time 5; <P> 4.altering a profile <P> sql> alter profile default failed_login_attempts 3 <P> sql> password_life_time 60 password_grace_time 10; <P> 5.drop a profile <P> sql> drop profile grace_5 [cascade]; <P> 6.create a profile : resource limit <P> sql> create profile developer_prof limit sessions_per_user 2 <P> sql> cpu_per_session 10000 idle_time 60 connect_time 480; <P> 7. view => resource_cost : alter resource cost <P> dba_Users,dba_profiles <P> 8. enable resource limits <P> sql> alter system set resource_limit=true;</P>
|
|
|
7楼#
发布于:2005-01-19 21:23
第七章:reorganizing data <P> 1.using expoty <P> $exp scott/tiger tables(dept,emp) file=c:\emp.dmp log=exp.log compress=n direct=y <P> 2.using import <P> $imp scott/tiger tables(dept,emp) file=emp.dmp log=imp.log ignore=y <P> 3.transporting a tablespace <P> sql>alter tablespace sales_ts read only; <P> $exp sys/.. file=xay.dmp transport_tablespace=y tablespace=sales_ts <P> triggers=n constraints=n <P> $copy datafile <P> $imp sys/.. file=xay.dmp transport_tablespace=y datafiles=(/disk1/sles01.dbf,/disk2 <P> /sles02.dbf) <P> sql> alter tablespace sales_ts read write; <P> 4.checking transport set <P> sql> DBMS_tts.transport_set_check(ts_list =>'sales_ts' ..,incl_constraints=>true); <P> 在表transport_set_violations 中查看 <P> sql> dbms_tts.isselfcontained 为true 是, 表示自包含</P>
|
|
|
8楼#
发布于:2005-01-19 21:22
第六章:LOAD数据 <P> 1.loading data using direct_load insert <P> sql> insert /*+append */ into emp nologging <P> sql> select * from emp_old; <P> 2.parallel direct-load insert <P> sql> alter session enable parallel dml; <P> sql> insert /*+parallel(emp,2) */ into emp nologging <P> sql> select * from emp_old; <P> 3.using sql*loader <P> sql> sqlldr scott/tiger \ <P> sql> control = ulcase6.ctl \ <P> sql> log = ulcase6.log direct=true</P>
|
|
|
9楼#
发布于:2005-01-19 21:22
第五章:约束 <P> 1.define constraints as immediate or deferred <P> sql> alter session set constraint[s] = immediate/deferred/default; <P> set constraint[s] constraint_name/all immediate/deferred; <P> 2. sql> drop table table_name cascade constraints <P> sql> drop tablespace tablespace_name including contents cascade constraints <P> 3. define constraints while create a table <P> sql> create table xay(id number(7) constraint xay_id primary key deferrable <P> sql> using index storage(initial 100k next 100k) tablespace indx); <P> primary key/unique/references table(column)/check <P> 4.enable constraints <P> sql> alter table xay enable novalidate constraint xay_id; <P> 5.enable constraints <P> sql> alter table xay enable validate constraint xay_id;</P>
|
|
|
上一页
下一页