Data Creation through SQL
This section deals with creation of tables, inserting, altering its structure, retrieving records and querying complex data by using SQL.
Using the CREATE TABLE Command
Oracle Database is made up of tables which contain columns (vertical) and rows (horizontal). Every column contains a data value at the intersection of a row and a column. The table definition contains the name of the attribute (property or field) and the category of the data in which the column contains. To create a table you use CREATE TABLE command. CREATE command is used to describe the structure of a table or any object.
Syntax:
CREATE TABLE <tablename> (column1 datatype, column2 datatype…);
Here, table name refers to the name of the entity or table column1 is the name of the first column and column2 the name of the second column and many more so on. For each column there must be an appropriate datatype that defines the type of data it can hold. The statement is terminated through a semi-colon.
The following instance describes the creation of a table.
Example
Create table EMPLOYEE ( Empno NUMBER,
Empname CHAR(10),
Doj DATE
);
This would shows: Table created.
In the above instance, an entity known as EMPLOYEE is created. It contains columns named Empno which can hold numeric data, Empname which contains character data and Doj which contains the date type of data. The Table names are always case-insensitive.
The structure of these data would look like:
Although creating tables, let consider the following points:
• Tablename must begin with an alphabet
• Tablename length must not go beyond 30 characters
• No two tables can have the similar name
• Reserved words of Oracle are not permitted