background image
<< Not Null and Primary Key | Ensuring Data Integrity >>
<< Not Null and Primary Key | Ensuring Data Integrity >>

Creating a Table with SQL Script

Creating and Using Tables
Creating and Using Database Objects 3-5
Click Add Column.
For Column Name, enter
NAME
.
For Type, enter
VARCHAR2
.
For Size, enter
80
.
8.
Enter information for the third column as follows:
Click Add Column.
For Column Name, enter
WEIGHT
.
For Type, enter
NUMBER
.
9.
Click OK.
SQL Developer generates the new table,
performance_parts
.
10.
In the Connections navigation hierarchy, click the plus sign (+) next to Tables to
expand the list of tables.
performance_parts
is a new table in the
hr
schema, listed between
locations
and
regions
.
You just created a new table,
performance_parts
. If you click the table, the table
will appear on the right side of the SQL Developer window, showing its new columns.
If you click the SQL tab, you will see the script that created this table.
In
Example 3­1
, you will create the
evaluations
table by entering the information
directly in the SQL Worksheet pane.
Example 3­1 Creating a Table in SQL Script
CREATE TABLE evaluations (
evaluation_id NUMBER(8,0),
employee_id NUMBER(6,0),
evaluation_date DATE,
job_id VARCHAR2(10),
manager_id NUMBER(6,0),
department_id NUMBER(4,0),
total_score NUMBER(3,0)
)
The results of the script follow.
CREATE TABLE succeeded.
You created a new table,
evaluations
. If you click the table, the table will appear on
the right side of the SQL Developer window, showing its new columns. If you click the
SQL tab, you will see the script that created this table. You may need to click the
Refresh icon.
In
Example 3­2
, you will create another table,
scores
, by entering the information in
the SQL Worksheet pane.
Example 3­2 Creating the SCORES Table
CREATE TABLE scores (
evaluation_id NUMBER(8,0),
performance_id VARCHAR2(2),
score NUMBER(1,0)
);