javaEEday07-DML-SQL1

This commit is contained in:
xx
2026-10-11 10:50:12 +08:00
parent 859ba987ec
commit a1bc25eb63
+45
View File
@@ -0,0 +1,45 @@
-- auto-generated definition
create table tb_emp
(
id int unsigned auto_increment comment 'ID'
primary key,
username varchar(20) not null comment '用户名',
password varchar(32) default '123456' null comment '密码',
name varchar(10) not null comment '姓名',
gender tinyint unsigned not null comment '性别, 说明: 1 男, 2 女',
image varchar(300) null comment '图像',
job tinyint unsigned null comment '职位, 说明: 1 班主任,2 讲师, 3 学工主管, 4 教研主管',
entrydate date null comment '入职时间',
dept_id int unsigned null comment '部门ID',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '修改时间',
constraint username
unique (username)
)
comment '员工表';
-- DML:数据操作语言
-- DML : 插入数据 - insert
-- 1. 为 tb_emp 表的 username, name, gender 字段插入值
insert into tb_emp (username,name,gender,create_time,update_time)
values('wuji','张无忌1',1,now(),now());
-- 2. 为 tb_emp 表的 所有字段插入值
insert into tb_emp values
(null,'zs','123','张三',1
,'1.png',1,'2015-01-01',1,now(),now());
insert into tb_emp
(id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time)
values
(null,'zs1','1234','张三1',1
,'1.png',1,'2015-01-01',1,now(),now());
-- 3. 批量为 为 tb_emp 表的 username , name , gender 字段插入数据
insert into tb_emp
(username,name,gender,create_time,update_time)
values
('wuji2','张无忌2',1,now(),now()),
('wuji3','张无忌3',1,now(),now()),
('wuji4','张无忌4',1,now(),now())
;