Creating and managing tables
Tables are the basic unit that store actual user data. Individual data records are referred to as rows, and fields are referred to as columns. Each table consists of one or more columns and rows.
Connect to example HR schema to execute the examples discussed in this chapter. The following is an example of the CREATE
statement to create a new table:
-- Create a new table CREATE TABLE emp ( emp_no NUMBER, -- Field that will store employee number emp_name VARCHAR2(50), -- Field that will store employee' name date_of_birth DATE, -- This will store employee's date of birth salary NUMBER(10,2) -- Field that will store employee' salary );
In the preceding code snippet, we have created a new table consisting of four columns. Each column is assigned a data type with respect to the values that it will store. The emp_no
column will store only number values, hence the NUMBER
data type is assigned. If we have to store an alpha-numeric value, we may consider using VARCHAR2
...