Managing Tables   «Prev 

Basic syntax for Creating a Table

CREATE TABLE tablename (colname1 datatype, colname2 datatype, colname 3 datatype ...)

  1. CREATE TABLE: The required CREATE TABLE keywords begin the DDL statement, which will create a table.
  2. tablename: The tablename must follow the rules for Oracle object names. It is followed by a list of column names and datatypes within parentheses.
  3. (colname1 datatype, colname2 datatype, colname3 datatype): Each colname must be followed by a datatype identifier. All column names must be unique within their table.

Relational tables: Using the Oracle-supplied datatypes you can create tables to store the rows inserted and manipulated by your applications. Tables have column definitions, and you can add or drop columns as the application requirements change. Tables are created via the create table command

Here is the create table command for the NEWSPAPER table:
create table NEWSPAPER (
Feature VARCHAR2(15) not null,
Section CHAR(1),
Page NUMBER
);

you can read it as:
Create a table called NEWSPAPER.

It will have three columns,
  1. named Feature (a varying-length character column),
  2. Section (a fixed-length character column), and
  3. Page (a numeric column).

The values in the Feature column can be up to 15 characters long, and every row must have a value for Feature.
Section values will all be 1 character long. In later modules you will see how to extend this simple command to add constraints, indexes, and storage clauses.
For now, the NEWSPAPER table will be kept simple so that the examples can focus on SQL.