create table EMPLOYEE
(
ID VARCHAR2(4) not null,
NAME VARCHAR2(15) not null,
AGE NUMBER(2) not null,
SEX CHAR(1) not null
);
INSERT INTO EMPLOYEE (ID, NAME, AGE, SEX) VALUES ('e101', 'zhao', 23, 'M');
INSERT INTO EMPLOYEE (ID, NAME, AGE, SEX) VALUES ('e102', 'jian', 21, 'F');
INSERT INTO EMPLOYEE (ID, NAME, AGE, SEX) VALUES ('e101', 'zhao', 23, 'M');
INSERT INTO EMPLOYEE (ID, NAME, AGE, SEX) VALUES ('e102', 'jian', 21, 'F');
COMMIT ;
现在插入age为空会报错
INSERT INTO EMPLOYEE (ID, NAME,AGE, SEX) VALUES ('e103', 'li',NULL, 'F');
我们可以修改表的age字段可以为空
alter table EMPLOYEE modify AGE null;
再次插入就可以了
INSERT INTO EMPLOYEE (ID, NAME,AGE, SEX) VALUES ('e103', 'li',NULL, 'F');
COMMIT ;
(修改age字段不能为空)
alter table EMPLOYEE modify AGE not null;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)