CREATE A TABLE

The first step in creating a database is to create one or more table to hold your data. A table has a columns(or fields) and rows. A single row of data is called a record. From a table, you might select a subset of rows or columns but the result always appears on screen or in print as another table. Each table must have an element that uniquely identifies each row of the table. This element, called the primary key, can be stored in one or in a combination of columns. In our example primary key is Id_number. A key column can be stored in other tables. When this is done, the column is called a foreign key.

   CREATE TABLE Worker (
   Id_number      CHAR(5) PRIMARY KEY,
   Name           CHAR(5), 
   Tel            NUMBER(10),
   Age            NUMBER, 
   Salary         NUMBER(3,2),
   Department     CHAR(10) REFERENCES 
                  DEPARTMENT(Skills),
   Date_of_birth  DATE
   );

In our example primary key is Id_number
Primary key column cannot contain null(worker
information is not useful without Id_number).
The foreign key is Department.
Department column refers to values for the
Department column in the Skills table. 


There are the major data types in ORACLE:
  • CHAR-character data, max size is 255. Default is 1 byte.
  • DATE-dates range(month and so on)
  • NUMBER-space for 40 digits
  • NUMBER(size,d)-with d digits after decimal point.

There are the basic elements of this command:
  • The words CREATE TABLE
  • The name of the table
  • An opening and a closing paranthesis
  • Column definition
  • SQL terminator

Back to SQL statements.