mysql中怎样创建霹葺檠溥非空属性的表,也可以在php中使用mysql的sql命令来完成:
首先我们来创建一个带有非空属性的表:
create table example4(
id int not null primary key,
stu_id int not null,
course_id int,
constraint s_f foreign key(course_id) references example2(course_id)
);
这里说明一下创建非空属性的结构与含义:
结构是:属性名 属性类型 not null;
比喻这里的: id int not null primary key,
还可以使用一个命令来修改已经创建好的表的属性,使它变为具有非空属性的如:
alter table example4 changed course_id int not null;