Exforsys.com
 
Home Tutorials Oracle 10g
 

Oracle 10g Tutorials : Creating Tables

 

Oracle 10g Free Training : Creating Tables

In this training you will learn about Creating Tables and Parallelizing Table Creation.


Creating Tables

To create a new table in your schema, you must have the CREATE TABLE system privilege. To create a table in another user's schema, you must have the CREATE ANY TABLE system privilege. Additionally, the owner of the table must have a quota for the tablespace that contains the table, or the UNLIMITED TABLESPACE system privilege.


Create tables using the SQL statement CREATE TABLE.


Creating a Table

When you issue the following statement, you create a table named Employee in the your default schema and default tablespace. The below mentioned code can either be executed through SQL*PLUS or iSQL*PLUS.




CREATE TABLE employee (


..........empno NUMBER(5) PRIMARY KEY,


..........ename VARCHAR2(15) NOT NULL,


..........job VARCHAR2(10),


..........mgr NUMBER(5),


..........hiredate DATE DEFAULT (sysdate),


..........sal NUMBER(7,2),


..........comm NUMBER(7,2),


..........deptno NUMBER(3) NOT NULL


); ..........................................................................





Figure 1. Table creation through SQL*PLUS



Parallelizing Table Creation


When you specify the AS SELECT clause to create a table and populate it with data from another table, you can utilize parallel execution. The CREATE TABLE ... AS SELECT statement contains two parts: a CREATE part (DDL) and a SELECT part (query). Oracle Database can parallelize both parts of the statement. The CREATE part is parallelized if one of the following is true:

A PARALLEL clause is included in the CREATE TABLE ... AS SELECT statement

An ALTER SESSION FORCE PARALLEL DDL statement is specified

If you parallelize the creation of a table, that table then has a parallel declaration (the PARALLEL clause) associated with it. Any subsequent DML or queries on the table, for which parallelization is possible, will attempt to use parallel execution.

The following simple statement parallelizes the creation of a table and stores the result in a compressed format, using table compression:


CREATE TABLE admin_emp_dept


..........PARALLEL COMPRESS


..........AS SELECT * FROM employee


..........WHERE deptno = 10;



Figure 2. Parallelizing Table creation through SQL*PLUS


Read Next: Oracle 10g Tutorials : Dropping Tables



 

 

Comments


christiangodi said:

  Hi
I want to know how to set default value for a DECIMAL
datatype.
September 2, 2005, 1:12 am

QUSAY said:

  very nice
May 8, 2007, 2:59 am

GV said:

  Very nice
June 20, 2007, 6:17 am

pranj said:

  This concept is very interesting
November 15, 2007, 5:19 am

DC said:

  This is nice. If you give the syntax then it will be more useful(coz I don't know which are all optional in Parallelizing Table creation through SQL*PLUS)
February 1, 2008, 8:42 am

Munish said:

  hi i want to know the code(oracle) in which employee id is incremented when a record is inserted and decremented when the record is deleted.
May 23, 2009, 5:02 pm

Avanish said:

  Hi,
I want to know how to create a database by using command prompt in Oracle 10g. Can any one tell me that how I can create a database.
May 30, 2009, 4:54 pm

ashish said:

  HI! Manish if you create sequence on employee id such as (create sequence employee_id_seq increment by 1 start with 1) and then if you give employee_id_seq.nextval into your insert statement then you can get employee id incremented by 1 automatically after every insert.
December 18, 2009, 1:41 am

haqdad said:

  hi
its very nice but i want to know how to creat it using GUI.
Thanks
February 9, 2010, 3:55 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape