Solved

How to Create a Schema

Posted on 2004-08-16
6
82,486 Views
Last Modified: 2012-06-27
I have a development Oracle 8i database that I'd like to create a new schema in.  I have 40 tables that I'd like to add to it.  I'm using PL/SQL Developer to help me along with any of the DDL but I don't see the Create Schema command anywhere.  What is the DDL I need to create a new schema and what are some of the things I need to consider?
0
Comment
Question by:jbauer22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Accepted Solution

by:
Pierrick LOUBIER earned 100 total points
ID: 11815050
The command is CREATE USER.
Full reference at http://www.ss64.com/ora/user_c.html

You'll have to allocate storage (quotas on tablespaces) to the user, and grant him privileges CREATE SESSION and TABLE (connected as SYSTEM). Then you're ready to add your tables.

Ownership makes user become a schema.
0
 
LVL 7

Assisted Solution

by:bvanderveen
bvanderveen earned 50 total points
ID: 11815109
First, use OEM and create a datafile and tablespace.  You'll probably want those separate from the other tablespaces.  Typically, we create 2 tablespaces/schema, one for indexes, one for tables like:

     XXXD --tablespace for schema  XXX tables
     XXXX -- tablespace for schema XXX indexes

Command to create schema is:

  create schema <schema_name>

In 8i and before, schema name was created automatically when a user account was created.  Now, they can be separate things.

You can do all of this with OEM, and it will protect you  (somewhat) from mistakes.
0
 
LVL 8

Assisted Solution

by:annamalai77
annamalai77 earned 50 total points
ID: 11817499
my dear friend,

i assume that u want to create a new tablespace and then create a user who belongs to that tablespace. in that case the steps r as follows.

create tablespace <tablespacename>
add datafile 'd:\anna.dbf' size 100 m;

create user anna identified by anna
default tablespace anna temporary tablespace temp;

grant create session, resource to anna;

there u r with the new tablespace and a new user who belongs to the anna tablespace;

regards
annamalai
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 9

Assisted Solution

by:pratikroy
pratikroy earned 50 total points
ID: 11819218
Hi there,

Oracle automatically creates a schema when you create a user. You can use CREATE USER command to create the SCHEMA.

If you have to create 40 tables, you can use 40 DDL statements (CREATE TABLE commands) to create these tables. Every statement will be treated as one transaction.

Alternatively, you can use the CREATE SCHEMA command.

Note that  CREATE SCHEMA command will not create the schema itself (SCHEMA would be created as mentioned above).
This statement lets you populate your schema with tables and views and grant privileges on those objects without having to issue multiple SQL statements in multiple transactions.

To execute a CREATE SCHEMA statement, Oracle executes each included statement. If all statements execute successfully, Oracle commits the transaction. If any statement results in an error, Oracle rolls back all the statements.

Suppose you wish to create a table and a view in the schema of user SCOTT, and grant access to hr, then you would issue the following command :

CREATE SCHEMA AUTHORIZATION scott
   CREATE TABLE product
      (color VARCHAR2(10)  PRIMARY KEY, quantity NUMBER)
   CREATE VIEW product_view
      AS SELECT color, quantity FROM product WHERE color = 'RED'
   GRANT select ON product_view TO hr;

Note : CREATE SCHEMA command was available in 8i also.

Hope this helps.
0
 
LVL 2

Author Comment

by:jbauer22
ID: 11822001
Please give me a chance to digest. I will post back.  Thanks!
0
 

Expert Comment

by:Bharath_Raj
ID: 25302345
Very Good....Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question