Saturday, April 21, 2007

JAVA 認證心得 -- SCMAD (3)

Security (both CLDC and MIDP)

##CONTINUE##

  • The following APIs are accessible to untrusted MIDlets, without explicit user confirmation.
  • The following APIs are accessible to untrusted MIDlets, with explicit user confirmation.
  • User permission can have one of three values.

    Ø “oneshot” means the permission has to be defined by user for every invocation of the API.

    Ø “blanket” means once the permission is defined by user, it remains that way for the life of the MIDlet application (from install to uninstall) till explicitly changed.

    Ø “session” means once the permission is defined by user, it remains that way for that run of the application (from start of MIDlet suite to stop).

  • Attributes defined within the manifest of the JAR are protected by the signature whereas attributes defined within the application descriptor are not secured.
  • The MIDlet.getAppProperty method returns the attribute value from the manifest if it is present. If not, the value from the application descriptor (if any) is returned
  • When an attribute appears in the manifest, it should not be overridden by a different value from the application descriptor. For trusted MIDlet suites, the value in the application descriptor must be equal to the value of the corresponding attribute in the manifest. Otherwise, the MIDlet suite would not be installed.
  • 1. Creating the signing certificate

    2. Insert Certificates into the application descriptor

    3. Creating the RSA-SHA-1 signature of the JAR

    4. Verify Signer Certificate

    5. Verify the MIDlet Suite JAR

  • The Base64 algorithm is used for encoding the signature of the JAR during a MIDlet Suite signing process.
  • Insert Certificates into the application descriptor

    Ø The certificate path includes the signer certificate and any necessary certificates but omitting the root certificate. The root certificate will be found on the device.

    Ø Each certificate in the path is encoded (using base64 but without line breaks) and inserted into the application descriptor as:

    MIDlet-Certificate--:

    := a number equal to 1 for first certification path in the descriptor or 1 greater than the previous number for additional certification paths. This defines the sequence in which the certificates are tested to see if the corresponding root certificate is on the device.

    := a number equal to 1 for the signer’s certificate in a certification path or 1 greater than the previous number for any subsequent intermediate certificates.

  • Creating the RSA-SHA-1 signature of the JAR

    Ø The signature of the JAR is created with the signers private key according to the EMSA-PKCS1-v1_5 encoding method of PKCS #1 version 2.0 standard[RFC2437].

    Ø The signature is base64 encoded, formatted as a single MIDlet-Jar-RSA-SHA1 attribute without line breaks and inserted in the application descriptor.

    MIDlet-Jar-RSA-SHA1:

  • If the MIDlet-Jar-RSA-SHA1 attribute is present in the application descriptor the JAR will be authenticated by verifying the signer certificates and JAR signature. If not, then treat as untrusted MIDlet suites.
  • Only trusted MIDlet suites can request permissions explicitly in the Jar manifest or application descriptor
  • An untrusted MIDlet suite is a MIDlet suite whose origin or JAR file integrity cannot be verified.
  • Trusted MIDlet suite installation
  • If any of the requested permissions are not present in the Protection Domain(Allowed or User) permission sets and the requested permission was marked as critical then the MIDlet suite does not have sufficient authorization and it will not be installed or invoked.
  • Permissions are the means to protect access to APIs or functions, which require explicit authorization before being invoked.
  • Protection Domain defines the permissions that may be granted to a MIDlet suite in that domain.
  • A protection domain defines a set of permissions and related interaction modes. A protection domain consist of

    Ø A set of permissions that should be allowed(Allowed)

    Ø A set of permissions that user may authorize(User); each with its user interaction mode

JAVA 認證心得 -- SCMAD (2)

CLDC 1.0/1.1

##CONTINUE##

  • Requirements by CLDC Sandbox model:

Ø Programmer can’t modify the class loading mechanism. Custom class-loading mechanisms are not allowed in CLDC.

Ø Classes must be verified to be valid by the CLDC pre-verifier and runtime verifier.

Ø Only a closed set of pre-defined profiles (like MIDP, WMA) are available to the programmer (you cannot use third-party libraries willy-nilly unless supported by the device!).

Ø Application programmer cannot write or use native code that is not part of the pre-defined packages (there is no Runtime.exec() method). Libraries containing native code cannot be downloaded into a device (unless it is a part of J2ME or that supplied by the device manufacturer).

  • WeakReference and Reference has been added to CLDC 1.1.
  • CLDC ensures application level security, which means a Java application can access only those libraries, system resources, and other componenets that the device and the Java application environment allows it to access. CLDC implementations is required to support Unicode characters, it means internationalization.
  • Exception Handling in CLDC

  • Event handling (low level or high level) is not in the scope of CLDC, It belongs to the profiles such as MIDP.
  • Both Runtime.gc() and System.gc() can be used in CLDC to persuade the Garbage Collector to reclaim unused memory.
  • Garbage Collector cannot be suspended or stopped manually.
  • The goal of a CLDC 1.1 specification

    Ø Smaller footprint

    Ø Dynamic downloading of applications

    Ø Focus on Application level programming

    Ø To remain as the “lowest common denominator” standard

  • CLDC supports the following four thread-safe collection classes

    Ø java.util.Vector

    Ø java.util.Stack

    Ø java.util.Hashtable

    Ø java.util.Enumeration (Interface)

  • When encountering any other error, the implementation should

    Ø Either halt the virtual machine in an implementation-specific manner.

    Ø Or throw an Error that is the nearest CLDC-Supported super class of the Error class that must be thrown according to the Java Language Specification

  • CLDC 1.1 requires that at least 32KB of volatile memory be available for the Virual Machine(VM) runtime and at least 160KB of non-volatile memory be available for the VM and CLDC libraries.
  • Presence of a minimal operating system or kernel to manage the hardware. Presence of one schedulable entity to run the virtual machine.
  • The default encoding is defined by the system property “microedition.encoding”
  • In CLDC 1.1, class java.lang.Math also includes support for trigonometric functions and square root calulation, and ceil and floor.
  • Any attempt to invoke finalize() method will result in a compilation error.
  • By default, the character property and case conversion facilities in CLDC assume the presence of ISO Latin-1 range of characters only. The implementations must provide support for character properties and case conversion for characters in the “Basic Latin” and “Latin-1 Supplement” blocks of Unicode 3.0
  • Class System

    - arraycopy(Object src, int src_position, Object dst, int dst_position, int length)

    - currentTimeMillis() , exit() , gc() , String getProperty(String key)

    - int identityHashCode(Object x)

  • String.intern()

    String.equalsIgnoreCase();

    Boolean.TRUE, Boolean.FALSE

    Date.toString()

    Random.nextInt(int i)

    Thread.interrupt();

  • Timezone in CLDC
  • CLDC performs a 2-step verification process. In the first step, which is called as preverification, the following processes take place

    Ø All the subrountines are inlined.

    Ø Special StackMap attributes are added into class files to facilitate runtime verification

    Ø Certain byte codes, which are irrelevant, are removed.

  • Since new attributes are added, a preprocessed file is approximately 10 to 15% larger than the orginal file.

JAVA 認證心得 -- SCMAD (1)

JTWI (JSR 185)

##CONTINUE##

  • In JTWI
  • The minimum application thread count is 10
  • text/vnd.sun.j2me.app-descriptor is the MIME type for JAD file.
  • Java Technology for Wireless Industry (JTWI) is a meta-specification. So JTWI does not define any API.
  • MIDIControl must be supported by a JTWI 1.0 compliant device to support MIDI playback. Note that this control need not be supported by a device that is only MIDP 2.0 compliant.
  • A JTWI 1.0 compliant device that supports MMAPI 1.1 specification must implement VolumeControl interface for the Player instances.
  • A JTWI 1.0 compliant device the value returned by the Canvas.getWidth() and Canvas.getHeight() method must be at least 125 pixels.
  • A JTWI 1.0 compliant device must implement a mechanism for selecting a phone number from the device phone book when the user is editing a TextBox or TextField and the constraint is TextField.PHONENUMBER.
  • TextField constant: ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL, DECIMAL
  • To identify a JTWI-complicant device and the implemented version of this specification the value of the system property microedition.jtwi.version must be “1.0”
  • A JTWI 1.0 compliant implementation must allow a MIDlet suite to create a minimum of 5 simultaneously running Timers.
  • The minimum volatile memory requirement for the Java Virtual Machine according to the JTWI 1.0 specifications is 256KB
  • The MIDlet-Data-Size attribute refers to the RMS data size.MIDlet-Data-Size should be the minimum amount of space for RMS that the application can work with. According to the JTWI 1.0 specification, this should be 30KB.
  • The implementation of SocketConnection using TCP sockets will throw java.securityException when an untrustedMIDlet suite attempts to connect to ports 80 and 8080, and 443
  • The JTWI specification requirements only for the untrusted domain for GSM compliant devices.

JAVA 認證心得 -- SCMAD

Sun Certified Mobile Application Developer for the Java 2 Platform, Micro Edition

這是 Java ME 的唯一一個認證考試, 當初覺得有空且對 J2ME 有興趣就去考了.準備時很辛苦,考起來很輕鬆, 認證考試的過程差不多都是這樣吧.

##CONTINUE##
考試內容項目有 :

  • JTWI (JSR 185)
  • CLDC 1.0/1.1
  • Security (both CLDC and MIDP)
  • Networking
  • Application Model/ Delivery/Lifecycle/Provisioning
  • MIDP Persistent Storage
  • Push Registry
  • MIDP UI API
  • MIDP Game API
  • MMAPI (Media using MIDP 2.0 and Mobile Media API)
  • Wireless Messaging API 1.1 (WMA)
  • Other
接下來幾篇是我當初準備此門考試的認證筆記

Thursday, April 19, 2007

Oracle9i DBA -- Database: Fundamentals I (20)

Other

##CONTINUE##

  • Query the data dictionary view DBA_FREE_SPACE to show how much free space is available in the database.
  • DBA_FREE_SPACE identifies the location and amount of free space by tablespace name, file ID, starting block ID, bytes, and blocks.
  • Query the data dictionary view DBA_SEGMENTS to display how much space is already used. And the location of all the tables and indexes by one users.
  • LGWR performs sequential writes from the redo log buffer cache to the redo log file under the following situations:

    1. When a transaction commits

    2. When the redo log buffer cache is one-third full

    3. When there is more than a megabyte of changes records in the redo log buffer cache

    4. Before DBWn writes modified blocks in the database buffer cache to the data files

    5. Every 3 seconds.

    Because the redo is needed for recovery, LGWR confirms the commit only after the redo is written to disk.

    LGWR can also call on DBWn to write to the data files.

    Note: DBWn does not write to the online redo logs.

  • There is a one-to-one correspondence between a user and server process, is called a dedicated server connection. When using a shared server configuration, it is possible for multiple user processes to share server processes.
  • PCTUSED for a data segment represents the minimum percentage of used space that the Oracle server tries to maintain for each data block of the table. A block is put back on the free list when its used space falls below PCTUSED. The free list of a segment is a list of blocks that are candidates for accommodating future inserts. A segment, by default, is created with one free list. Segments can be created with a higher number of free lists by setting the FREELISTS parameter of the storage clause.

Oracle9i DBA -- Database: Fundamentals I (19)

Using Globalization Support

##CONTINUE##

  • NLS_DATABASE_PARAMETERS shows the database character set and all the NLS parameter settings.
  • NLS_CHARACTERSET and the NLS_NCHAR_ CHARACTERSET are set when creating the database and cannot be changed later.

Auditing

  • Using DBMS_FGA the DBA creates an audit policy on the target table. Monitoring of data access based on content is implemented through DBMS_FGA.
  • Audit session, Audit session whenever successful, Audit session whenever not successful, Audit select on Account.person, Audit Delete on Account.person

Loading data into a database

  • The three models of concurrency are Intersegment concurrency, Intrasegment concurrency and Parallel concurrency

Oracle9i DBA -- Database: Fundamentals I (18)

Managing Roles

##CONTINUE##

  • Role Privileges include the following : Create Role, Alter Any Role, Drop Any Role, Grant Any Role
  • The SET ROLE command will turn off any other roles granted to the user.
  • You can’t assign a role to a user within a CREATE USER statement.
  • Max_Enabled_roles allow the user to limit the maximum number of database roles that the user can enable.
  • Default role is granted through alter user. Set role is use for enabling or disabling a role.
  • SET ROLE NONE is to turn off all roles granted to the user including default role. Drop role is drop the role and not disable it. Revoke role is used to revoke the role from the user and not just disable it.
  • The CREATE DATABASE , ALTER TABLESPACE privilege is SYSDBA privilege

Oracle9i DBA -- Database: Fundamentals I (17)

Managing Privileges

##CONTINUE##

  • System privilegea enable users to perform certain actions in the database while object privilege enables users to access and manipulate specific objects.
  • ALTER SESSION is a system privilege the information can be queried from DBA_SYS_PRIVS and USER_SYS_PRIVS views.
  • To ensure that system privileges allow access on all schemas except SYS the 07_DICTIONARY_ACCESSIBILITY parameter must be set to FALSE.
  • Oraenv is to switch between databases. Imp and exp are import and export. Sqlldr is for SQL*Loader
  • Execute privilege on a procedure is a object privilege the information can be gathered from ALL_TAB_PRIVS, USER_TAB_PRIVS, DBA_TAB_PRIVS
  • The Object privilege has a cascading effect. The System does not have any cascading effect.

Oracle9i DBA -- Database: Fundamentals I (16)

Managing Users

##CONTINUE##

  • A user can be authenticated by the data dictionary, operating system and network.
  • ORACNV is a script which can be executed to create a centralized repository of user accounts leading to ease of administration.
  • The unlimited tablespace privilege takes priority over quota settings.
  • To encrypt a user’s password the ORA_ENCRYPT_LOGIN parameter must be set to true.
  • OS_AUTHENT_PREFIX = “” is used to set user name format to a NULL prefix. OS_AUTHENT_PREFIX = OPS$ will allow the user to be authenticated by the OS or the Oracle server. Create User OPS$xxx IDENTIFIED EXTERNALLY will allow the user to be authenticated by the OS. REMOTE_OS_AUTHENT=TRUE specifies that a usr can be authenticated by a remote os.

Oracle9i DBA -- Database: Fundamentals I (15)

Managing Password Security and Resources
##CONTINUE##

  • Resource Limits can be set at session level and call level
  • Profiles are assigned to users by the CREATE USER or ALTER USER command
  • Enforce the resource limits

    1. by enabling the parameter with the ALTER SYSTEM command

    ALTER SYSTEM SET RESOURCE_LIMIT=TRUE

    2. Set the RESOURCE_LIMIT parameter to TRUE

  • Profiles cannot be created by the CREATE user command.


Wednesday, April 18, 2007

Oracle9i DBA -- Database: Fundamentals I (14)

Maintaining Data Integrity
##CONTINUE##

  • The utlexcptl.sql script can create the EXCEPTIONS table
  • CHECK constraint can be defined at both column and table level. Environment functions such as SYSDATE cannot be used to evaluate check condition.
  • Use the SET CONSTRAINTS statement to make constraints either DEFERRED or IMMEDIATE. The ALTER SESSION statement also has cluses to SET CONSTRAINTS to DEFERRED or IMMEDIATE.
  • DBA_CONSTRAINTS view is required to return the name of the foreign key constraint(CONSTRAINTS_NAME) and the referenced primary key(R_CONSTRAINTS_NAME).
  • Both unique and primary key constraints require index.

Oracle9i DBA -- Database: Fundamentals I (13)

Managing Indexes
##CONTINUE##

  • When you encounter index fragmentation, you can rebuild or coalesce the index. coalesce on an index is a block rebuild that is done online.
  • DBA_INDEXES : index name , index type, table owner, index owner.
  • Index rebuilds have the following characteristics

    O A new index is built using an existing index as the data source

    O Sorts are not needed when an index is built using an existing index, resulting in better performance.

    O The old index is deleted after the new index is build. During the rebuild, sufficient space is needed to accommodate both the old and the new index in their respective tablespaces.

    O The resulting index does not contain any deleted entries. This index uses space more efficiently

    O Queries can continue to use the existing index while the new index is being built.

  • DBA_IND_EXPRESSIONS : Provides information on columns or expressions used to create index
  • V$OBJECT_USAGE : Provide information on usage of index
  • Cluster maintains a “Cluster Index” that is used to locate rows and other information
  • B-tree indexes work well in single indexes rather than multiple indexes. B-tree support row-level both unique and non-unique indexes. B-tree index are suitable for retrival of a small number of rows.
  • The individual partitions are stored in separate segments whether it is a table partition or index partition. Partitions are beneficial in large objects that are read or written to simultaneously.

Tuesday, April 17, 2007

Oracle9i DBA -- Database: Fundamentals I (12)

Managing Tables

##CONTINUE##

  • The TZ environment variable can be used to decide the how the date will be displayed.
  • Each row in the table consists of a Row header (store the number of columns in a row) and Row Data (stores the column length and value).
  • A ROWID is composed of

    O Datafile number : Is assigned to each data object, such as table or index when it is created, and it is unique within the database.

    O Relative file number : is unique to each file within a tablespace

    O Block number : Represents the position of the block, containing the row, within the file.

    O Row number : Identifies the position of the row directory slot in the block header.

  • The portioning methods available in tables are Range, Hash, List and Composite. Range portioning is useful for tables with a range of value. Hash portioning is done using Hash algorithm. When all the values that are to be stored in a column are known, list partitioning can be used. Composite partitioning is a combination of hash and range partitioning.
  • The value of the parameter COMPATIBLE must be set to Oracle 8.1 or highter to use ROWID.
  • PCTFREE, NEXT, MINEXENTS can be modified after table creation.
  • Row Migration occurs due to low PCTFREE value. Row chaining the row is divided into smaller chunks. Row migration the entire row is moved to a new block.

Oracle9i DBA -- Database: Fundamentals I (11)

Managing Undo Data

##CONTINUE##

  • For sizing a UNDO tablespace the UNDO_RETENTION in seconds, number of undo data blocks generated per second and the overhead varies based on extent and file size (db_block_size) is required.
  • Use the ALTER SYSTEM command for dynamic switching between UNDO tablespaces

    ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2;

  • An undo segment with the status PENDING OFFLINE still contains active transactions. When no rows return from the query, then all transactions are complete, and the tablespace can be dropped.
  • Oracle server automatically creates an UNDO tablespace called SYS_UNDOTBS when no undo tablespace name is specified.
  • Deferred undo segments are dropped automatically
  • Before any DML operation the undo information will always be stored in the undo segment.
  • ‘Snapshot too old’ error may occur if there are long running queries. This generally takes place if the database has larger rollback extents. If the rollback extents are smaller, it will lead to undo extents getting deallocated.
  • V$ROLLSTAT is used to view the undo statistic and the segment number. V$ROLLNAME is show the segment number and name. V$UNDOSTAT contains snapshots of the performance of the undo tablespace. V$TRANSACTION and V$SESSION can be used to view the active transactions.
  • The ‘Set TRANSACTION ISOLATION LEVEL SERIALIZABLE’ will ensure read consistency of the transaction, though it is derimental to its performance.
  • The different type of undo segments are SYSTEM, NONSYSTEM and Deferred. The deferred segment is created when a tablespace is brought offline. They are used for recovery when the transaction is brought online.
  • USER_SEGMENT data dictionary contains all types of segments and their storage parameters for the user.

Oracle9i DBA -- Database: Fundamentals I (10)

Storage Structure and Relationships

##CONTINUE##

  • The default size for PCTFREE is 10 and of PCTUSED is 40 ,and the PCTINCREASE 50
  • Enabling automatic segment space management uses bitmaps instead of freelists to manage free space.
  • MAXTRANS specifies the number of concurrent transactions per block.
  • INITRANS, MAXTRANS,PCTFREE,PCTUSED are associated with the block.
  • Increasing the PCTFREE parameter can control Row migration in blocks
  • Optimal Flexible Architecture (OFA) : Oracle's recommended standard database architecture layout

    Three major rules:

    O Establish a directory structure where any database file can be stored on any disk resource

    O Separate objects with different behavior into different tablespaces

    O Maximize database reliability and performance by separating database components across different disk resources

  • The Oracle blocks are the finest level of data storage identity that contains multiple operating system blocks.
  • The Dictionary Managed Tablespace automatically assume the size of NEXT clause as 5 times the DB_BLOCK_SIZE and similarly INITIAL has to be twice of DB_BLOCK_SIZE
  • Extents are deallocated whenever the segments are altered, dropped or truncated.
  • Extents are allocated to segments when the segment are altered, created or extended.
  • Bootstrap segment (Cache segment), Table , Index and IOTs have their separate segments. Nested Tables stored in their own segment.
  • The effects of using TRUNCATE command are as follows:

    1. All rows in the table are deleted.

    2. No undo data is generated and the command commits implicitly because TRUNCATE TABLE is a DDL command.

    3. Corresponding indexes are also truncated.

    4. A table that is being referenced by a foreign key cannot be truncated.

    5. The delete triggers do not fire when this command is used.

    6. It reduces the number of extents allocated to the table to the original setting for MINEXTENTS.

Monday, April 16, 2007

Oracle9i DBA -- Database: Fundamentals I (9)

Managing Tablespace and Datafiles

##CONTINUE##

  • The free extents are managed in the tablespaces via the bitmaps. Bit values are used to indicate free or used space.
  • Automatic segment-space management can be enabled at the tablespace level only, for locally managed tablespaces.

    CREATE TABLESPACE data02

    DATAFILE ‘/u01/oradata/data02.dbf’ SIZE 5M

    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K

    SEGMENT SPACE MANAGEMENT AUTO;

    Ps. Free space is managed in the undo tablespace for a tablespace created with automatic segment-space management.

  • Using the CREATE TABLESPACE statement and specifying the blocksize clause can create tablespaces of non-standard block size. DB_CACHE_SIZE and DB_nK_CACHE_SIZE
  • The sum of the size of all data files specified in the CREATE TABLESPACE statement determines the initial size of a tablespace.
  • Datafiles can belong to only one tablespace and database
  • Moving Data Files:

    O ALTER DATABASE :

    ALTER DATABASE RENAME

    FILE '/u01/oradata/system01.dbf'

    TO '/u03/oradata/system01.dbf';

    1. Shut down the database.

    2. Use an operating system command to move the files.

    3. Mount the database.

    4. Execute the ALTER DATABASE RENAME FILE command.

    5. Open the database.

    SYSTEM tablespace cannot be taken offline, you must use this method to move

    data files in the SYSTEM tablespace.

    O Moving Data Files: ALTER TABLESPACE

    ALTER TABLESPACE userdata

    RENAME DATAFILE '/u01/oradata/userdata01.dbf'

    TO '/u01/oradata/userdata01.dbf';

    1.Take the tablespace offline.

    2. Use an operating system command to move or copy the files.

    3. Execute the ALTER TABLESPACE RENAME DATAFILE command.

    4. Bring the tablespace online.

    5. Use an operating system command to delete the file if necessary.

  • When a datafile is made read-only it can reside only on read-only media.
  • The Read-only tablespace can be deleted in the same manner the READ WRITE tablespace is.
  • The Default temporary tablespace is a locally managed tablespace.It cannlt be altered to a permanent tablespace.
  • When a tablespace is taken offline with the immediate clause, it need to do media recovery when bringing the tablespace online.

  • Locally managed tablespaces :

O Free extents recorded in bitmap
O Each bit corresponds to a block or group of blocks
O Bit value indicates free or used

O Reduced contention on data dictionary tables

O No undo generated when space allocation or deallocation occurs

O No coalescing required





  • Dictionary-managed tablespaces :

  • O Default method

    O Free extents recorded in data dictionary tables

    O Extents are managed in the data dictionary

    O Each segment stored in the tablespace can have a different storage clause

    O Coalescing required

    • Locally managed tablespaces have the following advantages over dictionary-managed tablespaces:

    1. Local management avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a undo segment or data dictionary table.

    2. Because locally managed tablespaces do not record free space in data dictionary tables, it reduces contention on these tables.

    3. Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.

    4. The sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace

    5. Changes to the extent bitmaps do not generate undo information because they do not update tables in the data dictionary (except for special cases such as tablespace quota information).

    • FOR RECOVERY clause freezes the checkpoint information wherever it is, by not updating it. Because a point-in-time recovery is desired, if a backup had to be taken, he would have updated the checkpoint information in datafile headers and control files by using either NORMAL(default) or TEMPORARY option
    • Dictionary Managed Tablespace cause recursive space management that slows down the systens, however it provides individual STORAGE clause to satisfy user custom needs. It has to be coalesced to fee space.
    • Segments in dictionary managed tablespaces can have a customized storage, this is more flexible than locally managed tablespaces but much less efficient.
    • Add more space in an existing TABLESPACE e

    ALTER DATABASE DATAFILE ‘/u1/d.dbf’ RESIZE 10M

    ALTER TABLESPACE tbs ADD DATAFILE ‘/u1/d2.dbf’ size 10M

    • Tablespace can store multiple datafiles on different disks, but don’t provide multiplexing (store same contents in multiple files)
    • Resizing a Tablespace

    A Tablespace can be resized by :

    O Changing the size of a data file

    - Automatically using AUTOEXTEND

    - Manually using ALTER DATABASE

    O Adding a data file using ALTER TABLESPACE

    • Enabling Automatic Extension of Data Files:

    When a data file is created, the following SQL commands can be used to enable automatic extension of the data file:

    - CREATE DATABASE

    - CREATE TABLESPACE ... DATAFILE

    - ALTER TABLESPACE ... ADD DATAFILE

    Query the DBA_DATA_FILES views to determine whether AUTOEXTEND is enabled.

Oracle9i DBA -- Database: Fundamentals I (8)

Managing Tablespace and Datafiles

##CONTINUE##

  • The free extents are managed in the tablespaces via the bitmaps. Bit values are used to indicate free or used space.
  • Automatic segment-space management can be enabled at the tablespace level only, for locally managed tablespaces.

    CREATE TABLESPACE data02

    DATAFILE ‘/u01/oradata/data02.dbf’ SIZE 5M

    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K

    SEGMENT SPACE MANAGEMENT AUTO;

    Ps. Free space is managed in the undo tablespace for a tablespace created with automatic segment-space management.

  • Using the CREATE TABLESPACE statement and specifying the blocksize clause can create tablespaces of non-standard block size. DB_CACHE_SIZE and DB_nK_CACHE_SIZE
  • The sum of the size of all data files specified in the CREATE TABLESPACE statement determines the initial size of a tablespace.
  • Datafiles can belong to only one tablespace and database
  • Moving Data Files:

    O ALTER DATABASE :

    ALTER DATABASE RENAME

    FILE '/u01/oradata/system01.dbf'

    TO '/u03/oradata/system01.dbf';

    1. Shut down the database.

    2. Use an operating system command to move the files.

    3. Mount the database.

    4. Execute the ALTER DATABASE RENAME FILE command.

    5. Open the database.

    SYSTEM tablespace cannot be taken offline, you must use this method to move

    data files in the SYSTEM tablespace.

    O Moving Data Files: ALTER TABLESPACE

    ALTER TABLESPACE userdata

    RENAME DATAFILE '/u01/oradata/userdata01.dbf'

    TO '/u01/oradata/userdata01.dbf';

    1.Take the tablespace offline.

    2. Use an operating system command to move or copy the files.

    3. Execute the ALTER TABLESPACE RENAME DATAFILE command.

    4. Bring the tablespace online.

    5. Use an operating system command to delete the file if necessary.

  • When a datafile is made read-only it can reside only on read-only media.
  • The Read-only tablespace can be deleted in the same manner the READ WRITE tablespace is.
  • The Default temporary tablespace is a locally managed tablespace.It cannlt be altered to a permanent tablespace.
  • When a tablespace is taken offline with the immediate clause, it need to do media recovery when bringing the tablespace online.

  • Locally managed tablespaces :

O Free extents recorded in bitmap
O Each bit corresponds to a block or group of blocks
O Bit value indicates free or used
  • O Reduced contention on data dictionary tables

    O No undo generated when space allocation or deallocation occurs

    O No coalescing required

    n Dictionary-managed tablespaces :

    O Default method

    O Free extents recorded in data dictionary tables

    O Extents are managed in the data dictionary

    O Each segment stored in the tablespace can have a different storage clause

    O Coalescing required

    n Locally managed tablespaces have the following advantages over dictionary-managed tablespaces:

    1. Local management avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a undo segment or data dictionary table.

    2. Because locally managed tablespaces do not record free space in data dictionary tables, it reduces contention on these tables.

    3. Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.

    4. The sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace

    5. Changes to the extent bitmaps do not generate undo information because they do not update tables in the data dictionary (except for special cases such as tablespace quota information).

    n FOR RECOVERY clause freezes the checkpoint information wherever it is, by not updating it. Because a point-in-time recovery is desired, if a backup had to be taken, he would have updated the checkpoint information in datafile headers and control files by using either NORMAL(default) or TEMPORARY option

    n Dictionary Managed Tablespace cause recursive space management that slows down the systens, however it provides individual STORAGE clause to satisfy user custom needs. It has to be coalesced to fee space.

    n Segments in dictionary managed tablespaces can have a customized storage, this is more flexible than locally managed tablespaces but much less efficient.

    n Add more space in an existing TABLESPACE e

    ALTER DATABASE DATAFILE ‘/u1/d.dbf’ RESIZE 10M

    ALTER TABLESPACE tbs ADD DATAFILE ‘/u1/d2.dbf’ size 10M

    n Tablespace can store multiple datafiles on different disks, but don’t provide multiplexing (store same contents in multiple files)

    n Resizing a Tablespace

    A Tablespace can be resized by :

    O Changing the size of a data file

    - Automatically using AUTOEXTEND

    - Manually using ALTER DATABASE

    O Adding a data file using ALTER TABLESPACE

    n Enabling Automatic Extension of Data Files:

    When a data file is created, the following SQL commands can be used to enable automatic extension of the data file:

    - CREATE DATABASE

    - CREATE TABLESPACE ... DATAFILE

    - ALTER TABLESPACE ... ADD DATAFILE

    Query the DBA_DATA_FILES views to determine whether AUTOEXTEND is enabled.

n

n