Monday, October 12, 2009

Useful SQL commands

A – How to create a Tablespace

Please log as “system” (with its valid password) using SqlPlus.

-- Create a 1GB tablespace from scratch.
CREATE TABLESPACE  LOGGING DATAFILE 'X:\full\path\to\XXXX.DBF' SIZE 1000M EXTENT MANAGEMENT LOCAL;
 
-- Change existing tablespace name.
ALTER TABLESPACE  RENAME TO ;
 
-- Change default user tablespace.
ALTER USER  DEFAULT TABLESPACE  QUOTA UNLIMITED ON ;
 
B – How to create a user for the Tablespace
 
CREATE USER  IDENTIFIED BY  DEFAULT TABLESPACE  TEMPORARY TABLESPACE temp;
GRANT SELECT ANY TABLE TO ;
GRANT UNLIMITED TABLESPACE TO ;
GRANT UPDATE ANY TABLE TO ;
GRANT RESOURCE TO ;
GRANT CONNECT TO ;
GRANT CREATE SESSION TO ;
grant query rewrite to ;
 
C – How to export your own database:
 
Exp system/@<instance> file= owner= log=explogfile.log
 
Parameters:
 - Oracle user name.
 - Oracle instance name.
 - System password.
 - Your database dump (like myDump.dmp).

No comments:

Post a Comment