Oracle includes five constraints, including primary key constraints (primarykey, the value of this attribute cannot be blank, and cannot be repeated. By default, this column is automatically indexed) and foreign key constraints (foreignk
Oracle includes five constraints, including the primary key constraint (primary key, the value of this attribute cannot be blank, and cannot be repeated. By default, this column is automatically indexed) and the foreign key constraint (foreign k
Table Creation
Oracle includes five constraints, including primary key constraints (primary key, the value of this attribute cannot be blank, and cannot be repeated. By default, this column is automatically indexed) and foreign key constraints (foreign key () references rname, with reference to integrity constraints, the value of this attribute must exist in the corresponding link), non-null constraints (not null), unique constraints (unique, not repeated, but it can be null, because in the database, the returned result of the expression null = null is unknown), check constraints (check (a in (a1, a2, a3 ))),, example
Create table r1
(Id numeric (15) primary key, // primary key constraint
Name varchar2 (15) not null, // non-null Constraint
Gender varchar2 (2) check (gender in ('M', 'F', 'O'), // simulate enumeration constraints, which are not supported in Oracle
Stu_number unique, // duplicate prohibited, but can be blank
Foreign key (stu_number) references r0); // foreign key constraint
Table Modification
1. Add a new property
Alter table r add id varchar2 (10 );
2. Reduce an existing attribute
Alter table r drop name;
3. Modify the restriction of an existing attribute
Alter table test1 modify grade number (5, 2) not null;
4. Modify the attribute name of an existing attribute
Alter table test1 rename column id to stu_number;