@Adrian
show create table <数据表名> \G;
mysql> create table tb_emp8
-> (
-> id int(11) primary key,
-> name varchar(22) unique,
-> deptId int(11) not null,
-> salary float default 0,
-> check(salary>0),
-> foreign key(deptId) references tb_dept1(id)
-> );
Query OK, 0 rows affected, 2 warnings (0.84 sec)
mysql> show create table tb_emp8\G
*************************** 1. row ***************************
Table: tb_emp8
Create Table: CREATE TABLE `tb_emp8` (
`id` int(11) NOT NULL,
`name` varchar(22) DEFAULT NULL,
`deptId` int(11) NOT NULL,
`salary` float DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `deptId` (`deptId`),
CONSTRAINT `tb_emp8_ibfk_1` FOREIGN KEY (`deptId`) REFERENCES `tb_dept1` (`id`),
CONSTRAINT `tb_emp8_chk_1` CHECK ((`salary` > 0))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
1 row in set (0.00 sec)
mysql> desc tb_emp8;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(22) | YES | UNI | NULL | |
| deptId | int(11) | NO | MUL | NULL | |
| salary | float | YES | | 0 | |
+--------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)