1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu OCA: Oracle Database 11g Administrator Certified Associate- P14 pptx

50 435 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 0,93 MB

Nội dung

Using DBCA to Create Oracle 11g Databases 481 When the creation process is complete, connect to the database with one of the tools such as SQL*Plus or Enterprise Manager to ensure that all the database options and components were installed properly. Logging into Enterprise Manager will give you an overview of the new database. By using the URL specified in Figure 9.31, you can invoke the Database Control home page. Log in using the SYSMAN account with the password you supplied in Figure 9.7. Figure 9.33 shows the home screen of Enterprise Manager Database Control. FIGURE 9.33 Enterprise Manager Database Control home page Configuring an Oracle Database Using the DBCA The DBCA lets you change various aspects of an existing database. To change the database configuration, select Configure Database Options on the DBCA Operations screen (shown earlier in this chapter in Figure 9.2). If the database is not started, the DBCA starts it for you automatically. You must connect to the database as a user who has DBA authority. 95127c09.indd 481 2/18/09 6:43:54 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 482 Chapter 9 N Creating an Oracle 11g Database Once you have selected and started the database, you can add options that may not have been previously included in the database. Using DBCA you can perform the following changes to database configuration: Add database components (refer to Figure 9.13). ÛN Change database security settings from pre-11 ÛN g default security setting to 11g enhanced security settings, or vice versa (refer Figure 9.24). Change the default connection mode for the database. You can change from dedicated ÛN server mode to shared server mode, or vice versa (refer Figure 9.22). Deleting an Oracle Database Using the DBCA You can also delete a database using the DBCA. On the Operations screen (Figure 9.2), choose Delete a Database, and click Next to open the Database screen. The DBCA lists all the databases available for deletion. Choose the database you want to delete. If you click Finish, the DBCA removes all files on the disk associated with the database you have chosen. If you are using Windows, the DBCA also removes the service associated with the database. Exercise 9.1 shows you how to delete a database manually using SQL*Plus. EXERCISE 9.1 Delete or Remove an Oracle Database Manually Some DBAs prefer to use a command-line interface to perform their tasks. You can delete a database using the command-line tool SQL*Plus. To do so, first connect to SQL*Plus as an administrator who has the ability to start up the database; that is, an administrator with either the SYSOPER or SYSDBA privilege. Here’s an example: /u01/app/oracle>sqlplus sys/**** as sysdba Once you are connected, you need to put the database in MOUNT mode. Issue the following command if the database is not running: Startup mount; Next, issue the following command: Drop database; This command deletes all the files associated with the database. If you are using raw disk devices, the special files created for these devices are not deleted. Also, you may have to remove any archived logs from the database archive area using the appropriate operating- system command. 95127c09.indd 482 2/18/09 6:43:54 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Using DBCA to Create Oracle 11g Databases 483 Managing Database Templates Using the DBCA As I explained earlier in this chapter, the DBCA can store and use XML-based templates to create your Oracle Database. As the DBA, you can manage these database-definition tem- plates. Saving a definition of your database in a template format makes it easier to perform various tasks. For example, you can copy a preexisting template to modify new database definitions. The template definition is normally stored in the $ORACLE_HOME/assistants/ dbca/templates directory on Unix and in the %ORACLE_HOME%\assistants\dbca\templates directory on Windows systems. The DBCA can use two types of templates: seed and nonseed. Seed templates are tem- plate definitions that contain database-definition information and the actual data files and redo log files. The advantage of a seed template is that the DBCA makes a copy of the data files and redo logs included in the definition file. These prebuilt data files include all schema information, which makes for a faster database-creation process. The seed templates carry a .dbc extension. The associated predefined data files are stored as files having a .dfb exten- sion. When you use a seed template, you can change the database name, the data-file locations, the number of control files and redo log groups, and the initialization parameters. Nonseed templates contain custom-defined database definitions. Unlike seed templates, they do not come with preconfigured data files and redo logs. Nonseed templates carry a .dbt extension. Now I’ll cover the various options you have to manage templates. Creating Template Definitions Using the DBCA You can use the DBCA interface to create new database templates. When you connect to the DBCA, select Manage Templates on the Operations screen (see Figure 9.2, shown ear- lier in this chapter), and click Next to open the Template Management screen, as shown in Figure 9.34. FIGURE 9.34 The DBCA Template Management screen 95127c09.indd 483 2/18/09 6:43:54 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 484 Chapter 9 N Creating an Oracle 11g Database You have three choices for creating templates. Table 9.4 summarizes your options. TABLE 9.4 Template-Creation Options Selection Description From an Existing Template Creates a new template definition from a preexisting tem- plate. This allows you to modify a variety of template settings, including parameters and data file storage characteristics. From an Existing Database (Structure Only) Creates a new template based on the structural characteris- tics of an existing database. The data files are created from scratch and will not include data from the original database. Choose this option when you want a database that is struc- turally like another database but does not contain any data. The database you are copying from can reside anywhere in your network. From an Existing Database (Structure As Well As Data) Creates a new template based on the structural character- istics of an existing database. The data files and all corre- sponding user data are included in the new database. Choose this option when you want an exact copy of an existing data- base. The database you are copying must reside on the same physical server as the new database you are creating. Depending on the option selected, you are presented with a set of forms to save your template definition. If you elect to create a template from an existing database, you will have to connect to the database so that the DBCA can obtain information about the database. You must connect to the database as a user who has DBA credentials to perform this task. If you are copying a definition from an existing template, you can configure the template by following a series of screens that are similar to those used to create a database. These screens allow you to configure the various aspects of the template, including initialization parameters and data file and redo log locations. Deleting Template Definitions Using the DBCA You can also delete an existing template definition. On the Operations screen (see Figure 9.2, shown earlier in this chapter), click Manage Templates. You will be presented with the Template Management screen (see Figure 9.34). Select the option Delete a Database Tem- plate. You can then choose the template to delete. When you remove the template, the DBCA removes the XML file from the system. 95127c09.indd 484 2/18/09 6:43:54 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Working with Oracle 11g Metadata 485 Working with Oracle 11g Metadata In addition to tables such as DEPARTMENTS and EMPLOYEES that store important business data, Oracle Databases also contain system tables that store data about the database. Examples of the type of information in these system tables include the names of all the tables in the database, the column names and datatypes of those tables, the number of rows those tables contain, and security information about which users are allowed to access those tables. This “data about the database” is referred to as metadata. As a DBA, you will frequently use this metadata when performing your administration tasks. An Oracle 11g database contains two types of metadata views: Data dictionary views ÛN Dynamic performance views ÛN The SYS user owns the data dictionary and dynamic performance views in the Oracle 11g database, and they are stored in the SYSTEM tablespace. During normal database opera- tion, Oracle uses the data dictionary frequently and updates the dictionary with the current status of the database components. The dictionary is also immediately updated when a DDL statement is executed. Data dictionary views and dynamic performance views are described in the next section. Data Dictionary Views Data dictionary views provide information about the database and its objects. Depending on which features are installed and configured, an Oracle 11g database can contain more than 1,600 data dictionary views. Data dictionary views have names that begin with DBA_ , ALL_ , and USER_ . Oracle creates public synonyms on many data dictionary views so users can access the views conveniently. The difference between the DBA_ , ALL_ , and USER_ views can be illustrated using the DBA_TABLES data dictionary view as an example. The DBA_TABLES view shows information on all the tables in the database. The corresponding ALL_TABLES view, despite its name, shows only the tables that a particular database user owns or can access. For example, if you were logged into the database as a user named SCOTT , the ALL_TABLES view would show all the tables owned by the user SCOTT and the tables to which SCOTT has been granted access by other users. The USER_TABLES view shows only those objects owned by a user. If the user SCOTT were to examine the USER_TABLES view, only those tables he owns would be displayed. Figure 9.35 shows a graphical representation of the relationship between the DBA_ , ALL_ , and USER_ views. Because the DBA_ views provide the broadest metadata information, they are generally the data dictionary views used by DBAs. Table 9.5 provides examples of DBA_ data diction- ary views. 95127c09.indd 485 2/18/09 6:43:55 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 486 Chapter 9 N Creating an Oracle 11g Database FIGURE 9.35 A comparison of data dictionary views USER_TABLES All tables owned by a particular database user. DBA_TABLES All tables in the entire database. Reserved for user accounts that have DBA privileges. ALL_TABLES All tables owned by a particular database user plus all tables to which the user has been granted access. TABLE 9.5 Examples of Data Dictionary Views Dictionary View Description DBA_TABLES Shows the names and physical storage information about all the tables in the database DBA_USERS Shows information about all the users in the database DBA_VIEWS Shows information about all the views in the database DBA_TAB_COLUMNS Shows all the names and datatypes of the table columns in the database DATABASE_PROPERTIES Displays database properties such as NLS parameters, default temporary and permanent tablespace names, database time zone, so on GLOBAL_NAME Shows the global database name 95127c09.indd 486 2/18/09 6:43:55 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Working with Oracle 11g Metadata 487 You can find a complete list of the Oracle 11g data dictionary views in Part II of the “Oracle Database Reference 11g Release 1 (11.1) Part Number B28320-01” document available at http://tahiti.oracle.com . Dynamic Performance Views Throughout database operation, Oracle updates a set of virtual tables to record the cur- rent database activity and status. These tables are called dynamic performance tables. Views are created on top of the dynamic performance tables for better grouping of infor- mation and to have names in a user-friendly format. The dynamic performance views are sometimes called fixed views, because they cannot be altered or removed by the database administrator. The dynamic performance tables begin with X$ . The dynamic performance view names begin with V_$ . Public synonyms are created on these views, and they begin with V$ . For example, the dynamic performance view with data file information is v_$datafile , whereas the public synonym is v$datafile . Depending on which features are installed and configured, an Oracle 11g database can contain approximately 480 dynamic performance views. Most of these views have names that begin with V$ . Table 9.6 describes a few of these dynamic performance views. TABLE 9.6 Examples of Dynamic Performance Views Dynamic Performance View Description V$DATABASE Contains information about the database, such as the database name and when the database was created V$VERSION Shows which software version the database is using V$OPTION Displays which optional components are installed in the database V$SQL Displays information about the SQL statements that database users have been issuing You can find a complete list of the Oracle 11g data dictionary views in Part III of the “Oracle Database Reference 11g Release 1 (11.1) Part Number B28320-01” document available at http://tahiti.oracle.com . 95127c09.indd 487 2/18/09 6:43:55 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 488 Chapter 9 N Creating an Oracle 11g Database Although the contents of the DBA_ and V$ metadata views are similar, there are some important differences between the two types. Table 9.7 compares these two types. TABLE 9.7 Data Dictionary vs. Dynamic Performance Views Data Dictionary Views Dynamic Performance Views The DBA_ views usually have plural names (for example, DBA_DATA_FILES ). The names of the V$ views are generally sin- gular (for example, V$DATAFILE ). The DBA_ views are available only when the database is open and running. Some V$ views are available even when the database is not fully open and running. The data contained in the DBA_ views is static and is not cleared when the database is shut down. The V$ views contain dynamic statistical data that is lost each time the database is shut down. The data dictionary view DICTIONARY shows information about the data dictionary and dynamic performance views in the database. DICT is a syn- onym for the DICTIONARY view. The COMMENTS column shows the purpose or contents of the view. The V$FIXED_TABLE view lists the dynamic perfor- mance tables and views in the database. The Oracle data dictionary and dynamic performance views are created while creating the database. The scripts to create the metadata are stored in the $ORACLE_HOME/rdbms/ admin directory. Several scripts are in this directory, and the script that creates the base dic- tionary objects is called catalog.sql . The catproc.sql script creates the PL/SQL packages and functionality to support PL/SQL in the database. You are not allowed to log in as SYS and modify the data dictionary views or update information directly using SQL. The only SYS -owned table you are allowed to delete records from is AUD$ . This table is used to keep data- base audit information. Managing Initialization-Parameter Files Oracle uses initialization-parameter files to store information about initialization parame- ters used when an Oracle instance starts. Oracle reads the parameter file to obtain informa- tion about how the Oracle instance should be sized and configured upon startup. 95127c09.indd 488 2/18/09 6:43:55 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Managing Initialization-Parameter Files 489 The parameter file can be a plain text file, commonly referred to as a pfile, or it can be a binary parameter file, commonly referred to as an spfile. You can use either type of file to configure instance and database options; however, there are some important differences between the two types of configuration files, as shown in Table 9.8. TABLE 9.8 Pfiles vs. Spfiles Pfile Spfile Text file that can be edited using a text editor. Binary file that cannot be edited directly. When changes are made to the pfile, the instance must be shut down and restarted before it takes effect. Parameter changes made to the database using ALTER​SYSTEM are updated in the spfile. Is called initinstance_ name.ora . Is called spfileinstance_ name.ora . Oracle instance reads only from pfile. Oracle instance reads and writes to the spfile. Can be created from an spfile using the create​pfile​from​spfile command. Can be created from a pfile using the create​spfile​from​pfile command. You can specify more than 285 documented configuration parameters in the pfile or spfile. Oracle 11g divides these parameters into two categories: basic and advanced. Oracle recommends you set only the basic initialization parameters manually. Oracle also recom- mends you do not modify the remaining parameters unless directed to do so by Oracle Support or to meet the specific needs of your application. Table 9.9 describes the basic ini- tialization parameters . A “Yes” in the Static column indicates that the parameter is static and cannot be modified dynamically without a database restart. TABLE 9.9 Oracle 11g Basic Initialization Parameters Parameter Name Static Description CLUSTER_DATABASE Yes Tells the instance whether it is part of a clustered environment. COMPATIBLE Yes Specifies the release level and feature set you want to be active in the instance. CONTROL_FILES Yes Designates the physical location of the database control files. DB_BLOCK_SIZE Yes Specifies the default database block size. The database block size specified at database creation cannot be changed. 95127c09.indd 489 2/18/09 6:43:55 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 490 Chapter 9 N Creating an Oracle 11g Database Parameter Name Static Description DB_CREATE_FILE_DEST No Specifies the directory location where database data files will be created if the Oracle-Managed Files feature is used. DB_CREATE_ONLINE_LOG_ DEST_n No Specifies the location(s) where the database redo log files will be created if the Oracle-Managed Files feature is used. DB_DOMAIN Yes Specifies the logical location of the database on the net- work. DB_NAME Yes Specifies the name of the database that is mounted by the instance. DB_RECOVERY_FILE_DEST No Specifies the location where recovery files will be writ- ten if the flash recovery feature is used. DB_RECOVERY_FILE_ DEST_SIZE No Specifies the amount of disk space available for storing flash recovery files. DB_UNIQUE_NAME Yes Specifies a globally unique name for the database within the enterprise. INSTANCE_NUMBER Yes Identifies the instance in a Real Application Clusters (RAC) environment. LDAP_DIRECTORY_​ SYSAUTH Yes Enables or disables Oracle Internet directory–based authentication for SYSDBA and SYSOPER connections to the database. LOG_ARCHIVE_DEST_n No Specifies as many as nine locations where archived redo log files are to be written. LOG_ARCHIVE_DEST_ STATE_n No Indicates how the specified locations should be used for log archiving. NLS_LANGUAGE Yes Specifies the default language of the database. NLS_TERRITORY Yes Specifies the default region or territory of the database. OPEN_CURSORS No Sets the maximum number of cursors that an individual session can have open at one time. PGA_AGGREGATE_TARGET No Establishes the overall amount of memory that all PGA processes are allowed to consume. PROCESSES Yes Specifies the maximum number of operating-system processes that can connect to the instance. REMOTE_LISTENER No Specifies a network name that points to the address or list of addresses of remote Oracle Net listeners. TABLE 9.9 Oracle 11g Basic Initialization Parameters (continued) 95127c09.indd 490 2/18/09 6:43:56 AM Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... /u01/app /oracle/ diag/rdbms/oca11g/OCA11G Diag Trace /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/trace Diag Alert /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/alert Diag Incident /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/incident Diag Cdump /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/cdump Health Monitor /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/hm Default Trace File /u01/app /oracle/ diag/rdbms/oca11g/OCA11G/trace/OCA 11G_ ora_9018.trc... Oracle Database Administrator s Guide 11g Release 1 (11.1) Part Number B28310-03” document All Oracle documentation can be accessed online at http://tahiti​ oracle. com F i g u r e   9 4 0  ​ EM View Alert Log Contents screen  ​ In Exercise 9.2, you’ll learn to create an Oracle Database 11g without using DBCA 512  Chapter 9    Creating an Oracle 11g Database n Exercise 9.2 Creating an Oracle 11g database. .. location where the Oracle 11g software is installed export ORACLE_ SID=OCA11G2 export ORACLE_ BASE=/u01/app /oracle export ORACLE_ HOME=/u01/app /oracle/ product/11.1.0 2 Create a password file using the ORAPWD utility This allows administrative logins to the Oracle 11g database from tools such as EM Database Control cd $ORACLE_ HOME/dbs orapwd file=orapwOCA11G2 3 Create an initialization-parameter file You can... repository in the database: SQL> @?/sysman/admin/emdrep/sql/emreposcre $ORACLE_ HOME SYSMAN mypwd TEMP ON 11 Configure EM Database Control: $ORACLE_ HOME/bin/emca -config dbcontrol db 513 514  Chapter 9    Creating an Oracle 11g Database n Summary In this chapter, you started off by learning how to create an Oracle 11g database using the Database Configuration Assistant Then I discussed the Oracle metadata... Oracle 11g pfile that contains both basic and advanced parameters: audit_file_dest=’/u01/app /oracle/ admin/OCA11G/adump’ audit_trail=’db’ compatible=’11.1.0.0.0’ control_files=(‘/u01/app /oracle/ oradata/OCA11G/control01.ctl’ ,’/u01/app /oracle/ oradata/OCA11G/control02.ctl’ ,’/u01/app /oracle/ oradata/OCA11G/control03.ctl’) db_block_size=8192 db_domain=’’ db_name=’OCA11G’ db_recovery_file_dest=’/u01/app /oracle/ flash_recovery_area’... to communicate with the Oracle Database When Oracle is started, these memory structures and background processes are initialized and started so that users can communicate with the Oracle Database Starting Up and Shutting Down an Oracle Instance  499 Whenever an Oracle Database is started, it goes through a series of steps to ensure database consistency When it starts up, a database passes through... creating new database templates Understand what each option is and when it should be used Describe the database startup modes  ​ Understand the various modes of database startup  ​ Understand what each database startup option is and when you might use the option Recognize how to start up an Oracle Database.  ​ Understand how to use the database tools  ​ to start up an Oracle Database Describe the database- shutdown... Creating an Oracle 11g Database n System parameters with non-default values: processes = 150 sga_target = 676M control_files = “/u01/app /oracle/ oradata/OCA11G/control01.ctl” control_files = “/u01/app /oracle/ oradata/OCA11G/control02.ctl” control_files = “/u01/app /oracle/ oradata/OCA11G/control03.ctl” db_block_size = 8192 compatible = “11.1.0.0.0” db_recovery_file_dest = “/u01/app /oracle/ flash_recovery_area”... 01/app /oracle/ oradata/OCA11G/control02.ctl,/u01/ app /oracle/ oradata/OCA11G/control03.ctl SQL> SELECT name, value 2 FROM v$spparameter 3 WHERE name LIKE ‘control%’ 4 AND isspecified = ‘TRUE’; NAME VALUE -control_files /u01/app /oracle/ oradata/OCA11G/control01.ctl control_files /u01/app /oracle/ oradata/OCA11G/control02.ctl control_files /u01/app /oracle/ oradata/OCA11G/control03.ctl... associated Oracle service Starting the Oracle service automatically starts the Oracle Database Changing Database Startup States Using SQL When the database is in the NOMOUNT or MOUNT state, you can go to the next state by using the ALTER DATABASE statement instead of shutting down the database and starting with the appropriate state option The following SQL statements show how to perform databaseavailability . control_files=(‘/u01/app /oracle/ oradata/OCA11G/control01.ctl’ ,’/u01/app /oracle/ oradata/OCA11G/control02.ctl’ ,’/u01/app /oracle/ oradata/OCA11G/control03.ctl’). control_files​​​​​​​​/u01/app /oracle/ oradata/OCA11G/control01.ctl control_files​​​​​​​​/u01/app /oracle/ oradata/OCA11G/control02.ctl control_files​​​​​​​​/u01/app /oracle/ oradata/OCA11G/control03.ctl

Ngày đăng: 14/12/2013, 15:15