Solved

How to Create a Schema

Posted on 2004-08-16
6
82,451 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

752 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