Maintain Data Integrity 5 - Table Level Definition Column Level Definition

Column-level definition
Column-level definition is to define constraints while defining columns,
such as defining primary key constraints in the department table
create table department4
(dept_id number(2) constraint pk_department_primary key,
name varchar2(12),
loc varchar2(12));

table-level definition
Table-level definition refers to defining constraints after all columns are defined. Note here:
not null constraints can only be defined at the column level.
Take defining primary key constraints and foreign key constraints when creating employee2 table as an example:
create table employee2
(emp_id number(4),name varchar2(15),dept_id number(2),
constraint pk_employee primary key(emp_id),
constraint fk_department foreign key (dept_id),
references department4(dept_id));

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326995912&siteId=291194637