SyntaxHighlighter JS

2014-01-12

How to add a new user/schema in Oracle

Question:
How do add a new user and schema in Oracle? (In Oracle, when you create a new user, you automatically create a new schema that has the same name as the username)

Answer:
Log in as a SYSTEM Oracle user and run the commands:

CREATE USER username
    IDENTIFIED BY password
    DEFAULT TABLESPACE user_tablespace
    QUOTA UNLIMITED ON user_tablespace
    TEMPORARY TABLESPACE temporary_tablespace;
 
GRANT CREATE SESSION TO username;
GRANT CREATE TABLE TO username;
GRANT CREATE VIEW TO username;
GRANT CREATE TRIGGER TO username;
GRANT CREATE PROCEDURE TO username;
GRANT CREATE SEQUENCE TO username;
GRANT CREATE SYNONYM TO username;
GRANT CREATE TYPE TO username;
GRANT UNLIMITED TABLESPACE TO username;

Oracle Doc on CREATE USER

You can find the default user_tablespace and temporary_tablespace via the SQL

SELECT *
FROM sys.database_properties
WHERE property_name like '%TABLESPACE%';


Question:
How do I delete a user?

Answer:

DROP USER username CASCADE;

No comments:

Post a Comment