|
Oracle Home |
|
Home > Oracle Database Administration (DBA) > Maintenance > Managing Database Tables and Indexes |
|
Oracle Database 10g Administration (DBA): Maintenance |
|---|
Managing Database Tables and Indexes |
|
CREATE TABLE EMP( EMPNO NUMBER(4),ENAME VARCHAR2(10 BYTE),JOB VARCHAR2(9 BYTE),MGR NUMBER(4),HIREDATE DATE,SAL NUMBER(7,2),COMM NUMBER(7,2),DEPTNO NUMBER(2) )TABLESPACE USERSPCTUSED 0PCTFREE 10INITRANS 1MAXTRANS 255STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT )LOGGING NOCOMPRESS NOCACHE ;
NOTE: The Automatic Segment Space Tablespace Management (ASSM) is new in Oracle9i and is implemented by adding the SEGMENT SPACE MANAGEMENT AUTO clause to the tablespace definition. ASM tablespaces automate freelist management and remove the ability to specify PCTFREE, PCTUSED, FREELISTS, and FREELIST GROUPS storage parameters.
Add a column to an existing table
ALTER TABLE EMP add (new_col varchar2(23));
Drop a column from an existing table
ALTER TABLE EMP drop column new_col2; (drop one column) ALTER TABLE EMP drop (new_col1, new_col2); (drop many columns)
When you drop a table column the column space remains used inside the data blocks and you may want to reorganize the table (using the imp/exp utility) to reclaim the free spaced from the dropped table column.
DROP TABLE EMP;DROP TABLE EMP cascade constraints; (Deletes all foreign keys that reference the table to be dropped, then drops the table.)DROP TABLE EMP purge; (10g: Normally, a table is moved into the recycle bin, if it is dropped. Using "purge" option the table is notmoved in recycle bin.)
CREATE UNIQUE INDEX PK_EMP ON EMP (EMPNO)LOGGING TABLESPACE USERSPCTFREE 10INITRANS 2MAXTRANS 255STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT);
This command creates an unique index on "empno" column on the EMP table and the index data will be stored in USERS tablespace.
More information about this subject ( Managing Database Tables and Indexes ) you can get from www.in-oracle.com
|
|
Home > Oracle Database Administration (DBA) > Maintenance > Managing Database Tables and Indexes |
|
Different Romanian Links/ Linkuri romanesti diferite |
Disclaimer: The views expressed on this web site are my own and do not reflect the views of Oracle Corporation. You may use the information from this site only at your risk. Copyright (c) 2009-2011 Paul Catalin Tomoiu. All rights reserved.