A dba question
Note: You can select and answer the following questions based on your own situation. You do not have to answer all the questions. You can also directly contact the interviewer to answer the questions without answering them.
I. SQL tuning class
1: List several table Connection Methods
Hash join/merge join/nest loop (cluster join)/index join
2: How to view SQL Execution plans without using third-party tools
Set autot on
Explain plan set statement_id = & item_id for & SQL;
Select * from table (dbms_xplan.display );
Http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10752/ex_plan.htm
3: How to Use CBO? What is the difference between CBO and rule?
When optimizer_mode = choose, if the table has statistical information (outside the Partition Table), the optimizer selects CBO. Otherwise, select RBO.
RBO follows a simple hierarchical methodology and uses 15 key points. When a query is received, the optimizer evaluates the number of key points used,
Then select the execution path of the optimal (minimum) level to run the query.
CBO tries to find the method to access data at the lowest cost. For the maximum throughput or the fastest initial response time, different
And select the lowest cost. Statistics on the table data content are used to determine the execution plan.
4: how to locate important (resource-consuming) SQL statements
Select SQL _text
From v $ SQL
Where disk_reads> 1000 or (executions> 0 and buffer_gets/executions> 30000 );
5: how to track the SQL of a session
Exec dbms_system.set_ SQL _trace_in_session (SID, serial #, & SQL _trace );
Select Sid, serial # from V $ session where Sid = (select Sid from V $ mystat where rownum = 1 );
Exec dbms_system.set_ev (& SID, & serial #, & event_10046, & level_12 ,'');
6: What are the most important aspects of SQL adjustment?
View the response time of the SQL statement (DB BLOCK gets/consistent gets/physical reads/sorts (Disk ))
7: your understanding of indexes (index structure, impact on DML, And why query performance is improved)
B-tree index/bitmap index/function index/patitional index (Local/Global)
Indexes can usually improve the performance of select, update, and delete operations, which will reduce the insert speed,
8: Can indexed queries improve query performance? Why?
Indexes exist to improve query performance,
If the index does not improve the query performance,
It can only be said that the index is incorrect, or that it is not the case
9: What is variable binding? What are the advantages and disadvantages of variable binding?
Variable binding is relative to text variables. The so-called text variables refer to Directly Writing query conditions in SQL,
Such SQL statements need to be parsed repeatedly under different conditions. Variable binding means that variables are used to replace direct writing conditions,
The query bind value is passed at runtime, and then bound for execution.
The advantage is that hard Parsing is reduced, CPU contention is reduced, and shared_pool is saved.
The disadvantage is that histogram cannot be used, which is difficult for SQL optimization.
10: stable (fixed) Execution Plan
Query_rewrite_enabled = true
Star_transformation_enabled = true
Optimizer_features_enable = 9.2.0
Create and use stored outline
Http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10752/outlines.htm#26854
This post:
Http://www.cnoug.org/viewthread.php? Tid = 27598
11: how to adjust the 8i and 9i in the sorting relation, and what is the role of the temporary tablespace?
In 8i, sort_area_size/sort_area_retained_size determines the memory required for sorting.
If the sorting operation cannot be completed in sort_area_size, the temp tablespace is used.
In 9i, if workarea_size_policy = auto,
Sort in PGA. Generally, 1/20 of pga_aggregate_target can be used for disk sort;
If workarea_size_policy = manual, the memory required for sorting is determined by sort_area_size.
When order by/group by/distinct/Union/create index/index rebuild/minus operations are performed,
If it cannot be completed in PGA or sort_area_size, the sorting will be performed in the temporary tablespace (Disk sort ),
The temporary tablespace is mainly used to complete disk sort in the system.
12: The table t (A, B, C, D) exists. Sort the records according to field C and display the records from to 30.
Create Table T (a number (8), B number (8), c Number (8), d Number (8 ));
/
Begin
For I in 1 .. 300 Loop
Insert into T values (mod (I, 2), I/2, dbms_random.value (1,300), I/4 );
End loop;
End;
/
Select * from (select C. *, rownum as rn from (select * from t order by c desc) c) Where rn between 21 and 30;
/
Select * from (select * from test order by c desc) X where rownum <30
Minus
Select * from (select * from test order by c desc) y where rownum <20 order by 3 DESC
Relatively poor performance compared with minus
Ii. Basic concepts of databases
1: pctused and pctfree
Pctused and pctfree control whether data blocks appear in freelist,
Pctfree controls the space reserved for update in the data block. When the free space in the data block is smaller than the space set by pctfree,
This data block is removed from freelist. When the free space of a block is greater than the space set by pct_used due to DML operations
Added to the freelist linked list.
2: Briefly describe the relationship between table/segment/extent/block
When a table is created, a data segment is created by default,
Each data segment contains the number of extents specified by Min extents,
A certain number of blocks are allocated to the storage parameters of each extent data tablespace.
3: describes the relationship between tablespace and datafile.
One tablespace can have one or more datafiles. Each datafile can only be in one tablespace,
The data in table is distributed in each datafile in tablespace using the hash algorithm,
Tablespace is a logical concept, while datafile physically stores various database objects.
4: Features of local tablespace management and dictionary tablespace management. What are the features of assm?
Local tablespace Management (LMT)
A new tablespace management mode that will appear after 8i. It uses bitmap to manage the space usage of the tablespace.
Dictionary table space (DMT)
A table space management mode that can be used before and after 8i. You can use the data dictionary to manage the space usage of the table space.
Segment space management (assm ),
It first appeared in oracle920 with assm. The Link List freelist is replaced by a bitmap. It is a binary array,
It can quickly and effectively manage storage extensions and free blocks, so it can improve the nature of segmented storage,
The segment created on the assm tablespace is also called bitmap managed segments (BMB segment ).
5: What is the role of rollback segments?
Transaction rollback: when the data in the transaction table is modified, the value before the data modification (that is, the previous image) will be stored in the rollback segment,
When you roll back a transaction, Oracle uses the data pre-image in the rollback segment to restore the modified data to the original value.
Transaction recovery: when the transaction is being processed, the routine fails, and the rollback segment information is saved in the Undo tablespace,
Oracle will use rollback to restore uncommitted data the next time it opens the database.
Read consistency: When a session is modifying data, other sessions will not be able to see the modifications not submitted by the session.
When a statement is being executed, it will not be able to see the uncommitted modifications (statement-level read consistency) after the statement is executed)
When Oracle executes the SELECT statement, Oracle follows the current system change number (system change NUMBER-SCN)
To ensure that any changes not submitted before the current SCN are not processed by this statement. It can be imagined that when a long query is being executed,
If other sessions change a data block to be queried for this query, Oracle constructs a read consistency view using the data pre-image of the rollback segment.
Http://www.itpub.net/showthread.php? S = & threadid = 10190 & Highlight = % BB % D8 % B9 % F6 % B6 % Ce % B5 % c4 % D7 % F7 % D3 % C3
6: What is the role of logs?
Records Database transactions to maximize data consistency and security
Redo log file: includes changes made to the database. In this case, you can enable data recovery in case of a fault. A database requires at least two redo log files.
Archive log file: an offline copy of the redo log file, which may be necessary to recover from a media failure.
Http://www.cnoug.org/viewthread.php? Tid = 17741 & Highlight = % C8 % D5 % D6 % Be
7: What are the main functions of SGA?
SGA: db_cache/shared_pool/large_pool/java_pool
Db_cache:
The database cache (block buffer) plays a key role in the operation and performance of the Oracle database,
It occupies the main part of the Oracle database SGA (System Shared Memory zone. Oracle Database uses LRU
The algorithm stores recently accessed data blocks in the cache to optimize access to disk data.
Shared_pool:
The size of the Shared Pool is important for Oracle performance.
The Shared Pool stores data dictionary high-speed buffering and fully resolved or compiled PL/SQL blocks and SQL statements and control structures.
Large_pool:
When using MTS configuration, the large_pool is used to maintain the session memory because UGA must be allocated in the SGA to maintain the user's session.
When using RMAN for backup, use the memory structure large_pool for disk I/O caches.
Java_pool:
The memory area prepared for Java procedure. If Java proc is not used, java_pool is not required.
8: What are the main functions and functions of Oracle system processes?
Data Writing Process (dbwr): responsible for writing changed data from the database buffer cache to the data file
Log write process (lgwr): writes changes in the redo log buffer to the online redo log file.
System Monitoring (SMON): Checks Database Consistency and, if necessary, starts database recovery when the database is opened.
Process Monitoring (pmon): clears resources when an oracle process fails.
Checkpoint Process (Chpt): updates the database status information in control files and data files whenever changes in the buffer cache are permanently recorded in the database.
Archiving process (arcn): backs up or archives a full log group during each log switch.
Job scheduler (cjq): responsible for scheduling and execution of jobs defined in the system to complete some predefined work.
Restore process (reco): to ensure the consistency of distributed transactions. In distributed transactions, either commit or rollback at the same time;
Iii. Backup Recovery
1: how to classify backups
Logical backup: exp/imp
Physical backup:
RMAN backup
Full backup/Incremental Backup (accumulation/difference)
Hot Backup: Alter tablespace begin/end backup;
Cold backup: offline backup (Database shutdown)
2: What does archive mean?
Archive logs: Archive logs (archived redo logs) must be created when Oracle wants to archive all online Log File groups ).
It is useful for database backup and recovery:
<1> database backup and online and archive log files Ensure that all submitted items can be recovered in case of an operating system or disk failure.
<2> online backup can be used if the archived logs are permanently saved when the database is enabled and normally used by the system.
The database can run in two different ways:
Noarchivelog or archivelog
When the database is used in noarchivelog mode, online logs cannot be archived,
If the database runs in archivelog mode, you can archive online logs.
3: If a table is dropped at 10:30:00, how can we restore it with comprehensive archiving and backup?
Manually copy back all backup data files
SQL> startup Mount;
SQL> alter database recover automatic until time '2017-08-04: 10: 30: 00 ';
SQL> alter database open resetlogs;
4: What is RMAN and what are its characteristics?
RMAN is an important DBA tool used to back up, restore, and restore Oracle databases,
RMAN can be used to back up and restore database files, archive logs, control files, and system parameter files. It can also be used to perform full or incomplete database recovery.
RMAN has three different user interfaces:
Command Line, Gui (Backup manager integrated in OEM), and API (used for integration into third-party backup software ).
It has the following features:
1) functions are similar to physical backup, but n times more powerful than physical backup;
2) Empty blocks can be compressed;
3) increment can be achieved at the block level;
4) The backup output can be packaged into a backup set, or the backup set can be split by fixed size;
5) the backup and recovery process can be automatically managed;
6) scripts can be used (in recovery Catalog)
7) Monitoring of Bad blocks
5: Features of standby
Standby Database: A high availability database solution launched by Oracle,
Log synchronization is used between the master and slave nodes to ensure data synchronization. The slave node acts as the backup of the master node.
It enables fast switchover and catastrophic recovery. It also supports physical and logical backup servers starting from 920.
The three data protection modes in 9i are:
1) maximize protection: maximum data protection and no data difference, lgwr will be transferred to the slave node at the same time,
The slave node must also completely receive log data before the master node confirms the transaction. If the network is poor, lgwr cannot transmit data, which may cause serious performance problems and cause the master node to go down.
2) Maximize availability: No data loss mode. Data divergence is allowed and asynchronous transmission is allowed.
Normally, the instance runs in the maximum protection mode. When the network between the master node and the slave node is disconnected or the connection is abnormal, the instance is automatically switched to the maximum performance mode,
The operation on the master node can continue. Poor network performance has a greater impact.
3) maximize performance: This mode can be said to be an alternative server mode inherited from 8i, Which is asynchronously transmitted,
No data synchronization check, data may be lost, but the maximum performance of the master node can be obtained. 9i is maximize performance by default when configuring data guard.
6: How do you design a backup policy for a system with a short recovery time (Database 50 GB, archiving 5 GB every day)
RMAN/No. 1 level 0 per month Level 1 per weekend/Wednesday Level 2 other daily level 2
Iv. System Management
1: For a system with system performance, describe your diagnosis and processing ideas.
1. Perform statspack to collect system information
Measure the test taker's knowledge about the system, determine whether the parameter settings are inappropriate, view top 5 events, and view top SQL.
2. Check v $ system_event/V $ session_event/V $ session_wait.
Determine the required resources (DB file sequential read) from V $ system_event.
Study v $ session_event in depth to determine the session involved in the wait event
Determine detailed resource contention from V $ session_wait (p1-p3 value: file_id/block_id/blocks, etc)
3. Use the V $ SQL/V $ sqltext/V $ sqlarea table to determine the SQL statements with large disk_reads and (buffer_gets/executions) values.
2: lists several methods for diagnosing Io, CPU, and performance conditions.
Top/vmstat
Statspack
SQL _trace/tkprof
Check v $ system_event/V $ session_event/V $ session_wait
Check v $ sqlarea (disk_reads or buffer_gets/executions large SQL)
3: What do you know about statspack?
Stapspack is a software package provided by Oracle to collect database running performance indicators. This software package has been significantly enhanced in 9i and 10g since 8i.
The number of auxiliary tables for the software package (tables that store related parameters and collected performance indicators) has increased from 25 to 43.
The number of collection-level parameters increases from 3 (0, 5, 10) to 5 (0, 5, 6, 7, 10)
By analyzing the collected performance indicators, the database administrator can learn in detail the current running status of the database and optimize and adjust database instances, wait events, and SQL statements.
Snapshot collected by statspack can be used to generate statistical trend charts for various performance indicators of the database.
4: If the system needs to create an index on a large table, you will consider those factors and how to minimize the impact on the application.
When the system is idle
Nologging option (nologging cannot be used if there is a consumer uard)
Large sort_ared_size or pga_aggregate_target
5: What do you know about raid1 + 0 and RAID5?
Raid 10 (or raid 1 + 0) is different from RAID 0 + 1. It uses a hard drive to form a RAID 1 array and then a RAID 0 array between RAID 1 arrays.
Raid 10 has the same good data transmission performance as RAID 0 + 1, but has higher reliability than RAID 0 + 1. The actual raid 10 array capacity is m × n/2,
Disk utilization is 50%. Raid 10 also requires at least four hard drives, which is expensive.
The reliability of RAID 10 is the same as that of RAID 1. However, the raid 10 hard drive is separated by data, which improves data transmission performance.
RAID 5 is similar to raid 3. The difference is that RAID 5's parity information is also separated and saved to all hard drives like data,
Instead of writing a specified hard drive, this eliminates the bottleneck of a single parity hard drive. The performance of the RAID 5 disk array is improved compared with that of RAID 3,
However, at least three hard drives are required. The actual capacity is m × (n-1), and the disk utilization is (n-1)/n.
V. Comprehensive and random class
1: Which part of Oracle are you best?
PL/SQL and SQL Optimization
2: Do you like Oracle? Do you like forums? Or which part of Oracle is preferred?
Like, SQL Optimization
3: Let's talk about the most interesting or difficult part of oracle.
Latch free processing
4: Why DBA?
Interest