mybatis join使用
需求
两张表 class 班级表 group小组表 一个班级会有多个小组
使用pgsql 外键关联
希望一条sql 查询所有的 班级和小组数据
数据库表
里面外键使用on delete cascade on update cascade
cascade 删除和更新父表的时候 字表跟着变化
使用powerdesigner默认的外键是Restrict 也就是不运行修改
这里使用cascade
注意点:使用了外键之后使用drop table IF exists t_person_class; 会报错
需要使用 drop table IF exists t_person_class cascade;
/*==============================================================*/
/* Table: t_person_class */
/*==============================================================*/
create table t_person_class (
id INT8 not null,
class_no VARCHAR(128) not null,
class_name VARCHAR(128) not null,
constraint PK_T_PERSON_CLASS primary key (id)
);
comment on table t_person_class is
'人员班级表';
/*==============================================================*/
/* Index: Idx_class_no */
/*==============================================================*/
create index Idx_class_no on t_person_class (
c