Interview

Monday, 20 April 2015

Create a new schema/new user in oracle 11g

Generally a schema in oracle is the same as an user. Oracle Database automatically creates a schema when you create a user. A file with the DDL file extension is an SQL Data Definition Language file.

Show already created tablespaces:

SQL> select tablespace_name from dba_tablespaces;

 Create tablespace:

SQL> create tablespace edcfc_tabspace
     datafile 'edcfc_tabspace.dat'
     size 10M autoextend on;
   
Create temporary tablespace (Temporaty tablespace is an allocation of 
space in the database that can contain transient data that persists only
for the duration of a session. This transient data cannot be recovered 
after process or instance failure.):
 
Create temporary tablespace :-
 
SQL> create temporary tablespace edcfc_tabspace_temp
     tempfile 'edcfc_tabspace_temp.dat'
     size 5M autoextend on;
 
Create User:-
 
 SQL > create user eDCFC
       identified by edcfc
       default tablespace EDCFC_TABSPACE
       temporary tablespace EDCFC_TABSPACE_TEMP; 
 
Grant some privileges:- 
 
  SQL > grant create session to edcfc;
        grant create table to edcfc;
        grant unlimited tablespace to edcfc;
 
Login as edcfc and check what privileges he has:- 
 
  SQL > select * from session_privs;
 
       PRIVILEGE
     ----------------------------------------
      CREATE SESSION
      UNLIMITED TABLESPACE
      CREATE TABLE 

With create table privilege the user can create tables:
 
SQL > CREATE TABLE "EMP" (emp_id .............);
 
SQL > INSERT INTO EMP VALUES (...........) ;


More information:

DDL
DBMS_METADATA
Schema objects
Differences between schema and user
Privileges
Creating user/schema
Creating tablespace
SQL Plus commands
        
   

No comments:

Post a Comment