Oracle maintenance common SQL statement

xiaoxiao2021-03-06  77

1, check the name and size of the table space

select t.tablespace_name, round (sum (bytes / (1024 * 1024)), 0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name; 2, see table space physical file name and the size of the select tablespace_name, file_id, file_name, round (bytes / (1024 * 1024), 0) total_space from dba_data_files order by tablespace_name; 3, view the name and size of the rollback select segment_name, tablespace_name, r.status, (initial_extent / 1024 ) InitialExtent, (next_extent / 1024) NextExtent, max_extents, v.curext CurExtent from dba_rollback_segs r, v $ rollstat v Where r.segment_id = v.usn ( ) order by segment_name; 4, view control file select name from v $ controlfile ; 5, view the log file select member from v $ logfile; 6, see the table space usage select sum (bytes) / (1024 * 1024) as free_space, tablespace_name from dba_free_space group by tablespace_name; SELECT A.TABLESPACE_NAME, A.BYTES Total, B.BYTES Used, C.bytes Free, (B.BYTES * 100) /A.BYTES "% use", (C.BYTES * 100) /A.BYTES "% free" from sys.sm $ TS_AVAIL A , SYS.SM $ TS_USED B, SYS.SM $ TS_FREE C WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME AND A.TABLESPACE_NAME = C.TABLESPACE_NAME; 7, to view the library database objects select owner, object_type, status, count (*) count # from all_objects group by owner, object_type, status; 8, view the database version Select version FROM Product_component_version Where SUBSTR (PRODUCT, 1,6) = 'Oracle'; 9, creation date, and archiving of Your database Select created, Log_Mode, Log_Mode From V $ database; 10, capture running SQL Column UserName Format A12 Column Opname Format A16 Column Progress Format A8 Select UserName, SID, OPNAME, ROUND (Sofar * 100 / Totalwork, 0) '%'

as progress, time_remaining, sql_text from v $ session_longops, v $ sql where time_remaining <> 0 and sql_address = address and sql_hash_value = hash_value / 11, to view the parameter information SELECT partition_name data table, high_value, high_value_length, tablespace_name, pct_free, pct_used, ini_trans , max_trans, initial_extent, next_extent, min_extent, max_extent, pct_increase, FREELISTS, freelist_groups, LOGGING, BUFFER_POOL, num_rows, blocks, empty_blocks, avg_space, chain_cnt, avg_row_len, sample_size, last_analyzed FROM dba_tab_partitions --WHERE table_name =: tname AND table_owner =: towner Order by partition_position 12, see the transaction, SELECT * from From V $ locked_Object; SELECT * from V $ Transaction; 13, find Object which process uses Select P.SPID, S.SID, S.Serial # serial_num, s. Username User_name, a.type object_type, s. type os_user_name, a.owner, a.object object_name, decode (Sign (48 - command), 1, to_char (command), 'action code #' to_char (command)) Action, p .program Oracle_Process, S.Terminal Terminal, S.Program Program, S.Status Session_Status from V $ Session S, V $ Access A, V $ Process P where s.paddr = p.addr and s.type = 'user' and a.sid = s.sid and a.object = 'SUBSCRIBER_ATTR' order by s.username, s.osuser 14, rollback view select rownum, sys.dba_rollback_segs.segment_name Name, v $ rollstat.extents Extents, v $ rollstat .rssize size_in_Bytes, v $ rollstat.xacts XActs, v $ rollstat.gets Gets, v $ rollstat.waits Waits, v $ rollstat.writes Writes, sys.dba_rollback_segs.status status from v $ rollstat, sys.dba_rollback_segs, v $ rollname WHERE V $ rollname.name ( ) =

转载请注明原文地址:https://www.9cbs.com/read-108485.html

New Post(0)