Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Create a Schema

Posted on 2004-08-16
6
Medium Priority
?
82,552 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 400 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 200 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 200 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 200 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses

886 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