Thursday, June 07, 2007

Oracle SQL command to create user

Since everytime I'll forget the exact commands, I shall record it here.

The following is the simplest way to create an Oracle user:

-- 1. Create Tablespace "MYDB"
CREATE TABLESPACE "MYDB"
LOGGING DATAFILE '/u02/oradata/ora10gdb/mydb.dbf'
SIZE 200M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;

-- 2. If temporary table space is needed, script to create temporary table space.
CREATE TEMPORARY TABLESPACE "TEMPORARY"
TEMPFILE '/u02/oradata/ora10gdb/TEMPORARY.dbf'
SIZE 50M
EXTENT MANAGEMENT LOCAL
UNIFORM SIZE 10M;

-- 3. Create User "MYDB"
CREATE USER "MYDB" PROFILE "DEFAULT" IDENTIFIED BY "MYDB"
DEFAULT TABLESPACE "MYDB" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK;
GRANT "CONNECT" TO "MYDB";
GRANT "RESOURCE" TO "MYDB";

No comments: