WINDOWS下的程序员出身,偶尔也写一些linux平台下小程序, 后转行数据库行业,专注于ORACLE和DB2的运维和优化。 同时也是ios移动开发者。欢迎志同道合的朋友一起研究技术。 数据库技术交流群:58308065,23618606
全部博文(599)
分类: Oracle
2010-09-10 10:56:47
DB_FILES and MAXDATAFILES parameters to be reduced, saving SGA and controlfile space.
ALTER TABLESPACE syntax has been updated to allow operations at the tablespace level, rather than datafile level. CREATE BIGFILE TABLESPACE command. The first two of the following statements have the same affect as the EXTENT MANAGEMENT LOCAL and SEGMENT SPACE MANAGEMENT AUTO clauses are the default actions, while the last statement would error.-- Valid statement. CREATE BIGFILE TABLESPACE mybigtbs DATAFILE '/u01/oracle/MYSID/mybigtbs01.dbf' SIZE 100G; -- Valid statement. CREATE BIGFILE TABLESPACE mybigtbs DATAFILE '/u01/oracle/MYSID/mybigtbs01.dbf' SIZE 100G EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; -- invalid statement. CREATE BIGFILE TABLESPACE mybigtbs DATAFILE '/u01/oracle/MYSID/mybigtbs01.dbf' SIZE 100G EXTENT MANAGEMENT DICTIONARY SEGMENT SPACE MANAGEMENT MANUAL;
SMALLFILE unless specified otherwise in the CREATE DATABASE command. Once the database is created the ALTER DATABASE command can be used to dynamically alter this setting.CREATE DATABASE mydb USER SYS IDENTIFIED BY password USER SYSTEM IDENTIFIED BY password SET DEFAULT BIGFILE TABLESPACE UNDO TABLESPACE undotbs DEFAULT TEMPORARY TABLESPACE temp; ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE; ALTER DATABASE SET DEFAULT SMALLFILE TABLESPACE;
BIGFILE keyword is no longer needed in the CREATE TABLESPACE statement, but creation of of a smallfile tablespace requires the SMALLFILE keyword.ALTER TABLESPACE command can be used to modify the size and autoextend functionality of bigfile tablespaces.ALTER TABLESPACE mybigtbs RESIZE 100G; ALTER TABLESPACE mybigtbs AUTOEXTEND ON NEXT 10G;
BIGFILE column (YES or NO) has been added to the DBA_TABLESPACES, USER_TABLESPACES and V$TABLESPACE views to indicate the tablespace type.-- Create group by adding existing tablespace. ALTER TABLESPACE temp TABLESPACE GROUP temp_ts_group; -- Add a new tablespace to the group. CREATE TEMPORARY TABLESPACE temp2 TEMPFILE '/u01/app/oracle/oradata/DB10G/temp201.dbf' SIZE 20M TABLESPACE GROUP temp_ts_group;
SELECT * FROM dba_tablespace_groups; GROUP_NAME TABLESPACE_NAME ------------------------------ ------------------------------ TEMP_TS_GROUP TEMP TEMP_TS_GROUP TEMP2 2 rows selected.
-- Assign group as the temporary tablespace for a user. ALTER USER scott TEMPORARY TABLESPACE temp_ts_group; -- Assign group as the default temporary tablespace. ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp_ts_group;
ALTER TABLESPACE temp2 TABLESPACE GROUP ''; SELECT * FROM dba_tablespace_groups; GROUP_NAME TABLESPACE_NAME ------------------------------ ------------------------------ TEMP_TS_GROUP TEMP 1 row selected.
-- Switch from the group to a specific tablespace. ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp; -- Remove the tablespace from the group. ALTER TABLESPACE temp TABLESPACE GROUP ''; -- Check the group has gone. SELECT * FROM dba_tablespace_groups; no rows selected
SKIP_UNUSABLE_INDEXES parameter can be set at instance level as well as session level and now defaults to TRUE. When set to TRUE Oracle will not attempt to use or report errors when an index is marked as unusable.ALTER SYSTEM and ALTER SESSION as shown below.ALTER SYSTEM SET SKIP_UNUSABLE_INDEXES = TRUE; ALTER SYSTEM SET SKIP_UNUSABLE_INDEXES = FALSE; ALTER SESSION SET SKIP_UNUSABLE_INDEXES = TRUE; ALTER SESSION SET SKIP_UNUSABLE_INDEXES = FALSE;
CREATE TABLE mytable (
column_1 NUMBER(10),
column_2 VARCHAR2(10),
column_3 NUMBER(10),
column_4 VARCHAR2(50)
);
CREATE INDEX myindex ON mytable (column_1, column_2, column_3) GLOBAL
PARTITION BY HASH (column_1, column_2)
(PARTITION myindex_part_1 TABLESPACE users,
PARTITION myindex_part_2 TABLESPACE users,
PARTITION myindex_part_3 TABLESPACE users,
PARTITION myindex_part_4 TABLESPACE users);
-- Add a new partition. ALTER INDEX myindex ADD PARTITION mytable_part_5; -- Reduce the number of partitions by 1. ALTER INDEX myindex COALESCE PARTITION; -- Rebuild partition. ALTER INDEX myindex REBUILD PARTITION mytable_part_1 TABLESPACE users; -- Rename partition. ALTER INDEX myindex RENAME PARTITION mytable_part_1 TO mytable_part_a; -- Clean up. DROP INDEX myindex; DROP TABLE mytable;