Example 2-7 Using %TYPE With Table Columns
CREATE TABLE employees_temp (empid NUMBER(6) NOT NULL PRIMARY KEY,
deptid NUMBER(6) CONSTRAINT check_deptid CHECK (deptid BETWEEN 100 AND 200),
deptname VARCHAR2(30) DEFAULT 'Sales');
DECLARE
v_empid employees_temp.empid%TYPE;
v_deptid employees_temp.deptid%TYPE;
v_deptname employees_temp.deptname%TYPE;
BEGIN
v_empid := NULL; -- this works, null constraint is not inherited
-- v_empid := 10000002; -- invalid, number precision too large
v_deptid := 50; -- this works, check constraint is not inherited
-- the default value is not inherited in the following
DBMS_OUTPUT.PUT_LINE('v_deptname: ' || v_deptname);
END;
/