?
Solved

How to Create a Schema

Posted on 2004-08-16
6
Medium Priority
?
82,520 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

718 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