Subscribe Search to Oracle-life
Subscribe
Via RSS By RSS
Via Mail By Mail

Friday, May 8, 2009

Oracle table and it's syntax and structure

Oracle table can be created using CREATE TABLE command. Table creation is a DDL language.
There is a syntax or structure to create table in Oracle database. For creating a table, table name must have to specify and column name, data type & size also should be mentioned.

Conditions of creating tables:

Bear in mind, two conditions must be fulfilled before creating any table in Oracle. Those conditions are:
  • You must have the privileged to create table.
  • A storage area must be needed to create any table.
Structure of creating table:

The structure or syntax of database table looks like the following:

CREATE TABLE [schema.] table
(column datatype [Default expr] [, ......]);

Description of the syntax of oracle table:
  • schema: schema is a collection of objects. Schema objects refer to logical structure which includes tables, views, synonyms, sequences etc. In the syntax, schema is the same as table owner's name.
  • table: it means the name of the table.
  • column: it refers the name of the table's column.
  • datatype: it refers the data type of the column and the datatype's size.
  • DEFAULT expr: it specifies the default value of the column. Sometimes, some values are not put in the INSERT statement. That time, the default value is inserted to that column value.
Note:
  • All CREATE TABLE syntax must be ended to a semicolon (;).
Example of creating table:
CREATE TABLE students(
firstName varchar2(20),
lastName varchar2(20),
age number(2)
);
In this example, a table named as "students" is created which has three columns: firstName, lastName and age. The syntax is ended by a semicolon (;).
Reblog this post [with Zemanta]

No comments:

Post a Comment