Oracle 10G XE provides a wizard to help you create a table. The wizard walks you through several steps for creating a table, taking you to the next step after you have entered valid entries for the current step. While scripts can be used to create a table, creating a table using the visual, form-based creation process is a lot simpler and less prone to errors. This tutorial describes a table to be created in the HR database with all the necessary ingredients for a typical database.
A table is an essential element of any relational database management system. Data stored in the columns and rows of a table, and the relationship that may exist between the various tables, is at the core of RDBMS. The creator of the table becomes the owner of the table. An owner cannot have two tables with the same name. Some of the other dos and don'ts for creating a table are:
The table name cannot use any of the keywords used in the system
It cannot be a combination of two names separated by a white space
The maximum length of a table is 28 characters.
The table name's first character should be alphabetic
The table name's other characters better be confined to numbers and
In any case, if and when you violate the rules you do get a error message telling you what was wrong. In that sense, you are covered. Since the Wizard tells you immediately what is wrong in some cases, you know what you have to do to correct it.
We will start with a very simple example of creating just one table called Htek_Employees for the Htek company. The Employee table will consist solely of the Employee information such as:
Columns in the table
In addition to this, to associate this information uniquely to an individual an Employee_ID is also added. This table will have 16 columns. The 16 columns are the attributes of the Employee physically stored in a table. A row in the table may contain values for each of these columns. For example, for an employee whose Employee_ID is 1, the details are:
If the Employee_ID is known, everything about this employee should be available from this table.
Column Data Types
For each column in the above table, the type of information it contains is different. While names are represented by 'text', hire_date and birth_date consists of 'date' type information. The salary contains 'money' type information. Telephone numbers and the Zip code consists of numerals, but they are not number type; who will ever think of adding two zip codes, or subtracting one telephone number from another? So these are no different than names. So the different columns may be stored as different data types. The Oracle table designer gives you options from which you can choose the data type that you may want to assign.