我在mariadb中创建了dept表,其中dno为主键。然后我创建了emp表,其中eno作为主键,dno作为外键,如下所示:
create table dept(dno int primary key,dname varchar(20));
create table emp(eno int primary key,ename varchar(20),dno int,foreign key(dno) references dept(dno));
然后我描述了两个表
DESC emp;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| eno | int(11) | NO | PRI | NULL | |
| ename | varchar(20) | YES | | NULL | |
| dno | int(11) | YES | MUL | NULL | |
+-------+-------------+------+-----+---------+-------+
desc dept;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| dno | int(11) | NO | PRI | NULL | |
| dname | varchar(20) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
从emp表中删除外键dno后,它在emp表中显示了相同的内容
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| eno | int(11) | NO | PRI | NULL | |
| ename | varchar(20) | YES | | NULL | |
| dno | int(11) | YES | MUL | NULL | |
+-------+-------------+------+-----+---------+-------+
如果删除外键约束
,如何删除mul值键列