Solved

How to Create a Schema

Posted on 2004-08-16
6
82,363 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now