Snippet Name: TABLESPACE: Alter Permanent Tablespace
Description: Various examples of manipulating permanent tablespace settings.
Also see: » TABLESPACE: Show contiguous space
» TABLESPACE: SYSAUX tablespace
» TABLESPACE: Tablespace management
» TABLESPACE: List tablespaces, files, ...
» TABLESPACE: Dropping Tablespaces
» TABLESPACE: Transportable tablespaces
» TABLESPACE: Tempfile operations
» TABLESPACE: Create temp tablespace
» TABLESPACE: Change UNDO tablespace
» TABLESPACE: Undo Tablespace
» TABLESPACE: SYSAUX Tablespace
» TABLESPACE: Set default tablespace type
» TABLESPACE: Oracle Managed Auto-extend...
» TABLESPACE: Permanent Tablespace Using...
» TABLESPACE: Using Raw Devices
» TABLESPACE: permanent tablespace
Comment: (none)
Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 12th, 2009
|
-- Add Datafile:
ALTER TABLESPACE ADD DATAFILE <file_name>,
<integer><K | M | G | T>
[REUSE]
<autoextend> <ON | OFF>
NEXT <integer><K | M | G | T>
MAXSIZE <integer><K | M | G | T | UNLIMITED>
ALTER TABLESPACE tspace ADD DATAFILE
'/u02/oracle/oradata/sales_data.dbf' SIZE 25M
AUTOEXTEND OFF;
ALTER TABLESPACE tspace ADD ADD DATAFILE
'c:\oracle\product\oradata\testbed.dat' SIZE 10M
AUTOEXTEND ON;
-- take offline:
ALTER TABLESPACE <tablespace_name> OFFLINE;
ALTER TABLESPACE tspace OFFLINE;
-- put on-line:
ALTER TABLESPACE <tablespace_name> ONLINE;
ALTER TABLESPACE tspace ONLINE;
-- make tablespace read only:
ALTER TABLESPACE <tablespace_name> READ ONLY;
ALTER TABLESPACE tspace READ ONLY;
SELECT tablespace_name, status
FROM dba_tablespaces;
-- Note that READ ONLY prevents DML but does not
-- include DDL using DROP and TRUNCATE!
-- make a tablespace read/write:
ALTER TABLESPACE <tablespace_name> READ WRITE;
ALTER TABLESPACE tspace READ WRITE;
SELECT tablespace_name, status
FROM dba_tablespaces;
-- prepare tablespace for backup:
ALTER TABLESPACE <tablespace_name> BEGIN BACKUP;
ALTER TABLESPACE tspace BEGIN BACKUP;
END Tablespace Backup ALTER TABLESPACE <tablespace_name> END BACKUP;
ALTER TABLESPACE tspace END BACKUP;
-- rename tablespace:
ALTER TABLESPACE <tablespace_name> RENAME TO <new_tablespace_name>;
SELECT tablespace_name
FROM dba_tablespaces;
SELECT table_name
FROM dba_tables
WHERE tablespace_name = 'SALES';
ALTER TABLESPACE sales RENAME TO sales_data;
SELECT tablespace_name
FROM dba_tablespaces;
SELECT table_name
FROM dba_tables
WHERE tablespace_name = 'SALES_DATA';
|