创建表格
table表:
(2)exam:
CREATE TABLE `exam` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) CHARACTER SET 'utf8mb4' NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4;
mysql> desc exam;
+-------+------------------+------+-----+----------+----------------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+------+---------+----------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(80) | NO | | NULL | |
+-------+------------------+------+------+---------+----------------------+
2 rows in set (0.00 sec)
(3)score:
CREATE TABLE `score` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`student_id` INT(11) NOT NULL,
`subject_id` INT(11) NOT NULL,
`exam_id` INT(11) NOT NULL,
`score` INT(11) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4;
mysql> desc score;
+---------------+---------+------+-----+---------+-------------------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------+------+------+---------+-------------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| student_id | int(11) | NO | | NULL | |
| subject_id | int(11) | NO | | NULL | |
| exam_id | int(11) | NO | | NULL | |
| score | int(11) | NO | | NULL | |
+---------------+---------+-------+-----+------------+-----------------------+
5 rows in set (0.00 sec)
(4)student:
CREATE TABLE `student` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`class_id` INT(11) NOT NULL,
`sex` CHAR(10) CHARACTER SET 'utf8' NOT NULL,
`name` VARCHAR(80) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (`id`))
(5)subject:
CREATE TABLE `subject` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (`id`))
插入数据
insert into 'class'(‘1', 'name')
values(1, '高一二班');
修改数据(三班-->五班)
updata 'class' set 'name' = '高一五班
where ' 'name' = '高一三班;
修改id:
updata 'class' set 'name' = '高一五班
where ' 'id' = '5;
删除数据(三班-->五班)
delete from 'class'
where ' 'id' = '3;