阅读:4738回复: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:20
第二章:表空间管理 <P> 1.create tablespaces <P> sql> create tablespace tablespace_name datafile 'c:\oracle\oradata\file1.dbf' size 100m, <P> sql> 'c:\oracle\oradata\file2.dbf' size 100m minimum extent 550k [logging/nologging] <P> sql> default storage (initial 500k next 500k maxextents 500 pctinccease 0) <P> sql> [online/offline] [permanent/temporary] [extent_management_clause] <P> 2.locally managed tablespace <P> sql> create tablespace user_data datafile 'c:\oracle\oradata\user_data01.dbf' <P> sql> size 500m extent management local uniform size 10m; <P> 3.temporary tablespace <P> sql> create temporary tablespace temp tempfile 'c:\oracle\oradata\temp01.dbf' <P> sql> size 500m extent management local uniform size 10m; <P> 4.change the storage setting <P> sql> alter tablespace app_data minimum extent 2m; <P> sql> alter tablespace app_data default storage(initial 2m next 2m maxextents 999); <P> 5.taking tablespace offline or online <P> sql> alter tablespace app_data offline; <P> sql> alter tablespace app_data online; <P> 6.read_only tablespace <P> sql> alter tablespace app_data read only|write; <P> 7.droping tablespace <P> sql> drop tablespace app_data including contents; <P> 8.enableing automatic extension of data files <P> sql> alter tablespace app_data add datafile 'c:\oracle\oradata\app_data01.dbf'size 200m <P> sql> autoextend on next 10m maxsize 500m; <P> 9.change the size fo data files manually <P> sql> alter database datafile 'c:\oracle\oradata\app_data.dbf'resize 200m; <P> 10.Moving data files: alter tablespace <P> sql> alter tablespace app_data rename datafile 'c:\oracle\oradata\app_data.dbf' <P> sql> to 'c:\oracle\app_data.dbf'; <P> 11.moving data files:alter database <P> sql> alter database rename file 'c:\oracle\oradata\app_data.dbf' <P> sql> to 'c:\oracle\app_data.dbf'; </P>
|
|
|
2楼#
发布于:2005-01-19 21:21
第三章:表 <P> 1.create a table <P> sql> create table table_name (column datatype,column datatype]....) <P> sql> tablespace tablespace_name [pctfree integer] [pctused integer] <P> sql> [initrans integer] [maxtrans integer] <P> sql> storage(initial 200k next 200k pctincrease 0 maxextents 50) <P> sql> [logging|nologging] [cache|nocache] <P> 2.copy an existing table <P> sql> create table table_name [logging|nologging] as subquery <P> 3.create temporary table <P> sql> create global temporary table xay_temp as select * from xay; <P> on commit preserve rows/on commit delete rows <P> 4.pctfree = (average row size - initial row size) *100 /average row size <P> pctused = 100-pctfree- (average row size*100/available data space) <P> 5.change storage and block utilization parameter <P> sql> alter table table_name pctfree=30 pctused=50 storage(next 500k <P> sql> minextents 2 maxextents 100); <P> 6.manually allocating extents <P> sql> alter table table_name allocate extent(size 500k datafile 'c:/oracle/data.dbf'); <P> 7.move tablespace <P> sql> alter table employee move tablespace users; <P> 8.deallocate of unused space <P> sql> alter table table_name deallocate unused [keep integer] <P> 9.truncate a table <P> sql> truncate table table_name; <P> 10.drop a table <P> sql> drop table table_name [cascade constraints]; <P> 11.drop a column <P> sql> alter table table_name drop column comments cascade constraints checkpoint 1000; <P> alter table table_name drop columns continue; <P> 12.mark a column as unused <P> sql> alter table table_name set unused column comments cascade constraints; <P> alter table table_name drop unused columns checkpoint 1000; <P> alter table orders drop columns continue checkpoint 1000 <P> data_dictionary : dba_unused_col_tabs </P>
|
|
|
3楼#
发布于:2005-01-19 21:21
第四章:索引 <P> 1.creating function-based indexes <P> sql> create index summit.item_quantity on summit.item(quantity-quantity_shipped); <P> 2.create a B-tree index <P> sql> create [unique] index index_name on table_name(column,.. asc/desc) tablespace <P> sql> tablespace_name [pctfree integer] [initrans integer] [maxtrans integer] <P> sql> [logging | nologging] [nosort] storage(initial 200k next 200k pctincrease 0 <P> sql> maxextents 50); <P> 3.pctfree(index)=(maximum number of rows-initial number of rows)*100/maximum number of rows <P> 4.creating reverse key indexes <P> sql> create unique index xay_id on xay(a) reverse pctfree 30 storage(initial 200k <P> sql> next 200k pctincrease 0 maxextents 50) tablespace indx; <P> 5.create bitmap index <P> sql> create bitmap index xay_id on xay(a) pctfree 30 storage( initial 200k next 200k <P> sql> pctincrease 0 maxextents 50) tablespace indx; <P> 6.change storage parameter of index <P> sql> alter index xay_id storage (next 400k maxextents 100); <P> 7.allocating index space <P> sql> alter index xay_id allocate extent(size 200k datafile 'c:/oracle/index.dbf'); <P> 8.alter index xay_id deallocate unused;</P>
|
|
|
4楼#
发布于: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>
|
|
|
5楼#
发布于: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>
|
|
|
6楼#
发布于: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>
|
|
|
7楼#
发布于: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>
|
|
|
8楼#
发布于: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>
|
|
|
9楼#
发布于: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> |
|
|
上一页
下一页