OCA/OCP Oracle Database 11g All-in-One Exam Guide 126 TIP There is some overlap between V$ views and data dictionary views. For instance, V$TABLESPACE has a row for every tablespace, as does DBA_ TABLESPACES. Note that as a general rule, V$ views are singular and data dictionary views are plural. But there are exceptions. Exercise 3-4: Query Data Dictionary and Dynamic Performance Views In this exercise, investigate the physical structures of the database by querying views. 1. Connect to the database with SQL*Plus or SQL Developer. 2. Use dynamic performance views to determine what datafiles and tablespaces make up the database as well as the size of the datafiles: select t.name,d.name,d.bytes from v$tablespace t join v$datafile d on t.ts#=d.ts# order by t.name; 3. Obtain the same information from data dictionary views: select tablespace_name,file_name,bytes from dba_data_files order by tablespace_name; 4. Determine the location of all the controlfile copies. Use two techniques: select * from v$controlfile; select value from v$parameter where name='control_files'; 5. Determine the location of the online redo logfile members, and their size. As the size is an attribute of the group, not the members, you will have to join two views: select m.group#,m.member,g.bytes from v$log g join v$logfile m on m.group#=g.group# order by m.group#,m.member; Two-Minute Drill Describe the Stages of Database Startup and Shutdown • The stages are NOMOUNT, MOUNT, and OPEN. • NOMOUNT mode requires a parameter file. • MOUNT mode requires the controlfile. • OPEN mode requires the datafiles and online redo logfiles. Set Database Initialization Parameters • Static parameters cannot be changed without a shutdown/startup. • Other parameters can be changed dynamically, for the instance or a session. • Parameters can be seen in the dynamic performance views V$PARAMETER and V$SPPARAMETER. Chapter 3: Instance Management 127 PART I Use the Alert Log and Trace Files • The alert log contains a continuous stream of messages regarding critical operations. • Trace files are generated by background processes, usually when they encounter errors. Use Data Dictionary and Dynamic Performance Views • The dynamic performance views are populated from the instance and the controlfile. • The data dictionary views are populated from the data dictionary. • Dynamic performance views accumulate values through the lifetime of the instance, and are reinitialized at startup. • Data dictionary views show information that persists across shutdown and startup. • Both the data dictionary views and the dynamic performance views are published through synonyms. Self Test 1. You issue the URL https://127.0.0.1:5500/em and receive an error. What could be the problem? (Choose three answers.) A. You have not started the database listener. B. You have not started the dbconsole. C. The dbconsole is running on a different port. D. You are not logged on to the database server node. E. You have not started the Grid Control agent. F. You have not started the database. 2. Which files must be synchronized for a database to open? (Choose the best answer.) A. Datafiles, online redo logfiles, and controlfile B. Parameter file and password file C. All the multiplexed controlfile copies D. None—SMON will synchronize all files by instance recovery after opening the database OCA/OCP Oracle Database 11g All-in-One Exam Guide 128 3. During the transition from NOMOUNT to MOUNT mode, which files are required? (Choose the best answer.) A. Parameter file B. Controlfile C. Online redo logfiles D. Datafiles E. All of the above 4. You shut down your instance with SHUTDOWN IMMEDIATE. What will happen on the next startup? (Choose the best answer.) A. SMON will perform automatic instance recovery. B. You must perform manual instance recovery. C. PMON will roll back uncommitted transactions. D. The database will open without recovery. 5. You have created two databases on your computer and want to use Database Control to manage them. Which of the following statements are correct? (Choose two answers.) A. You cannot use Database Control, because it can only manage one database per computer. B. You must use Grid Control, as you have multiple databases on the computer. C. You can use Database Control, if you contact it on different ports for each database. D. You must set the ORACLE_SID variable appropriately before starting each Database Control console. 6. You issue the command SHUTDOWN, and it seems to hang. What could be the reason? (Choose the best answer.) A. You are not connected as SYSDBA or SYSOPER. B. There are other sessions logged on. C. You have not connected with operating system or password file authentication. D. There are active transactions in the database; when they complete, the SHUTDOWN will proceed. 7. What action should you take after terminating the instance with SHUTDOWN ABORT? (Choose the best answer.) A. Back up the database immediately. Chapter 3: Instance Management 129 PART I B. Open the database, and perform database recovery. C. Open the database, and perform instance recovery. D. None—recovery will be automatic. 8. What will be the setting of the OPTIMIZER_MODE parameter for your session after the next startup if you issue these commands: alter system set optimizer_mode=all_rows scope=spfile; alter system set optimizer_mode=rule; alter session set optimizer_mode=first_rows; A. all_rows B. rule C. first_rows (Choose the best answer.) 9. The LOG_BUFFER parameter is a static parameter. How can you change it? (Choose the best answer.) A. You cannot change it, because it is static. B. You can change it only for individual sessions; it will return to the previous value for all subsequent sessions. C. You can change it within the instance, but it will return to the static value at the next startup. D. You can change it in the parameter file, but the new value will only come into effect at the next startup. 10. Which of these actions will not be recorded in the alert log? (Choose two answers.) A. ALTER DATABASE commands B. ALTER SESSION commands C. ALTER SYSTEM commands D. Archiving an online redo logfile E. Creating a tablespace F. Creating a user 11. Which parameter controls the location of background process trace files? (Choose the best answer.) A. BACKGROUND_DUMP_DEST B. BACKGROUND_TRACE_DEST C. DB_CREATE_FILE_DEST D. No parameter—the location is platform specific and cannot be changed OCA/OCP Oracle Database 11g All-in-One Exam Guide 130 12. Which of these views can be queried successfully in nomount mode? (Choose all correct answers.) A. DBA_DATA_FILES B. DBA_TABLESPACES C. V$DATABASE D. V$DATAFILE E. V$INSTANCE F. V$SESSION 13. Which view will list all tables in the database? (Choose the best answer.) A. ALL_TABLES B. DBA_TABLES C. USER_TABLES, when connected as SYS D. V$FIXED_TABLE Self Test Answers 1. þ B, C, and D. There will always be an error if the database console process has not been started or it is on a different port, and since the URL used a loopback address, there will be an error if the browser is not running on the same machine as the console. ý A, E, and F. A and F are wrong because these are not a problem; the listener and the database can both be started if the console is accessible. E is wrong because the Grid Control agent is not necessary for Database Control. 2. þ A. These are the files that make up a database, and must all be synchronized before it can be opened. ý B, C, and D. B is wrong because these files are not, strictly speaking, part of the database at all. C is wrong because an error with the controlfile will mean the database cannot even be mounted, never mind opened. E is wrong because SMON can only fix problems in datafiles, not anything else. 3. þ B. Mounting the database entails the opening of all copies of the controlfile. ý A, C, D, and E. A is wrong because the parameter file is only needed for NOMOUNT. C, D, and E are wrong because these file types are only needed for open mode. 4. þ D. An immediate shutdown is clean, so no recovery will be required. ý A, B, and C. These are wrong because no recovery or rollback will be required; all the work will have been done as part of the shutdown. Chapter 3: Instance Management 131 PART I 5. þ C and D. Database Control will be fine but must be started for each database and contacted on different ports for each database. ý A and B. A is wrong because you can use Database Console, but you will need separate instances for each database. B is wrong because while Grid Control may be a better tool, it is by no means essential. 6. þ B. The default shutdown mode is SHUTDOWN NORMAL, which will hang until all sessions have voluntarily disconnected. ý A, C, and D. A and C are wrong because these would cause an error, not a hang. D is wrong because it describes SHUTDOWN TRANSACTIONAL, not SHUTDOWN NORMAL. 7. þ D. There is no required action; recovery will be automatic. ý A, B, and C. A is wrong because this is one thing you should not do after an ABORT. B is wrong because database recovery is not necessary, only instance recovery. C, instance recovery, is wrong because it will occur automatically in mount mode at the next startup. 8. þ B. The default scope of ALTER SYSTEM is both memory and spfile. ý A and C. A is wrong because this setting will have been replaced by the setting in the second command. C is wrong because the session-level setting will have been lost during the restart of the instance. 9. þ D. This is the technique for changing a static parameter. ý A, B, and C. A is wrong because static parameters can be changed—but only with a shutdown. B and C are wrong because static parameters cannot be changed for a running session or instance. 10. þ B and F. Neither of these affects the structure of the database or the instance; they are not important enough to generate an alert log entry. ý A, C, D, and E. All of these are changes to physical or memory structures, and all such changes are recorded in the alert log. 11. þ A. This is the parameter used to determine the location of background trace files. ý B, C, and D. B is wrong because there is no such parameter. C is wrong because this is the default location for datafiles, not trace files. D is wrong because while there is a platform-specific default, it can be overridden with a parameter. 12. þ E and F. These views are populated from the instance and will therefore be available at all times. ý A, B, C, and D. A and B are data dictionary views, which can only be seen in open mode. C and D are dynamic performance views populated from the controlfile, and therefore only available in mount mode or open mode. OCA/OCP Oracle Database 11g All-in-One Exam Guide 132 13. þ B. The DBA views list every appropriate object in the database. ý A, C, and D. A is wrong because this will list only the tables the current user has permissions on. C is wrong because it will list only the tables owned by SYS. D is wrong because this is the view that lists all the dynamic performance views, not all tables. CHAPTER 4 Oracle Networking Exam Objectives In this chapter you will learn to • 052.5.1 Configure and Manage the Oracle Network • 052.5.2 Use the Oracle Shared Server Architecture 133 OCA/OCP Oracle Database 11g All-in-One Exam Guide 134 Networking is an integral part of the client-server database architecture that is fundamental to all modern relational databases. The Oracle database had the potential for client-server computing from the beginning (version 1, released in 1978, made a separation between the Oracle code and the user code), but it was only with version 4 in 1984 that Oracle introduced interoperability between PC and server. True client-server support came with version 5, in 1986. This chapter introduces the Oracle Net services. Oracle Net was previously known as Sqlnet, and you will still hear many DBAs refer to it as such. The default Oracle Net configuration is dedicated server. In a dedicated server environment, each user process is connected to its own server process. An alternative is shared server, where a number of user processes make use of a pool of server processes that are shared by all the sessions. Generally speaking, DBAs have been reluctant to use shared server, but there are indications that Oracle Corporation would like more sites to move to it, and certainly knowledge of the shared server architecture is vital for the OCP examination. Configure and Manage the Oracle Network Oracle Net is the enabling technology for Oracle’s client-server architecture. It is the mechanism for establishing sessions against a database instance. There are several tools that can be used for setting up and administering Oracle Net, though it can be done with nothing more than a text editor. Whatever tool is used, the end result is a set of files that control a process (the database listener, which launches server processes in response to connection requests) and that define the means by which a user process will locate the listener. Oracle Net and the Client-Server Paradigm There are many layers between the user and the database. In the Oracle environment, no user ever has direct access to the database—nor does the process that the user is running. Client-server architecture guarantees that all access to data is controlled by the server. A user interacts with a user process: this is the software that is run on their local terminal. For example, it could be Microsoft Access plus an ODBC driver on a Windows PC; it could be something written in C and linked with the Oracle Call Interface (or OCI) libraries; it could even be your old friend SQL*Plus. Whatever it is, the purpose of the user process is to prompt the user to enter information that the process can use to generate SQL statements. In the case of SQL*Plus, the process merely waits for you to type something in—a more sophisticated user process will present a proper data entry screen, will validate your input, and then when you click the Submit button will construct the statement and send it off to the server process. The server process runs on the database server machine and executes the SQL it receives from the user process. This is your basic client-server split: a user process generating SQL, that a server process executes. The execution of a SQL statement goes through four stages: parse, bind, execute, and fetch. In the parse phase your server Chapter 4: Oracle Networking 135 PART I process works out what the statement actually means, and how best to execute it. Parsing involves interaction with the shared pool of the instance: shared pool memory structures are used to convert the SQL into something that is actually executable. In the bind phase, any variables are expanded to literal values. Then the execute phase will require more use of the instance’s SGA, and possibly of the database. During the execution of a statement, data in the database buffer cache will be read or updated and changes written to the redo log buffer, but if the relevant blocks are not in the database buffer cache, your server process will read them from the datafiles. This is the only point in the execution of a statement where the database itself is involved. And finally, the fetch phase of the execution cycle is where the server process sends the result set generated by the statement’s execution back to the user process, which should then format it for display. Oracle Net provides the mechanism for launching a server process to execute code on behalf of a user process. This is referred to as establishing a session. Thereafter, Oracle Net is responsible for maintaining the session: transmitting SQL from the user process to the server process, and fetching results from the server process back to the user process. Figure 4-1 shows the various components of a session. A user interacts with a user process; a user process interacts with a server process, via Oracle Net; a server process interacts with the instance; and the instance, via its background processes, interacts with the database. The client-server split is between the user process generating SQL and the server process executing it. This split will usually be physical as well as logical: there will commonly be a local area network between the machines hosting the user processes and the machine hosting the server processes. But it is quite possible for this link to be over a wide area network, or conversely to run the user processes on the server machine. Oracle Net is responsible for establishing a session, and then for the ongoing communication between the user process and the server process. Figure 4-1 The database is protected from users by several layers of segregation. . Database 11g All-in-One Exam Guide 134 Networking is an integral part of the client-server database architecture that is fundamental to all modern relational databases. The Oracle database had. started for each database and contacted on different ports for each database. ý A and B. A is wrong because you can use Database Console, but you will need separate instances for each database. B. OCA/ OCP Oracle Database 11g All-in-One Exam Guide 126 TIP There is some overlap between V$ views and data dictionary views. For instance, V$TABLESPACE has a row for every tablespace, as does