• Hibernate课程 初探多对多映射2-1 创建数据库表


    --创建表

    -- 创建项目表

    create table project(  proid int(10) not null comment '项目Id',  proname varchar(30) comment '项目名称' );

    -- 创建员工表

    create table employee2(  empid int(10)   comment '员工id',  empname varchar(20) comment '员工姓名' );

    -- 创建项目员工关联 中间表

    create table pro_emp(  proid int(10) not null ,  empid int(10) not null );

    -- 添加外键

    alter table pro_emp add constraint fk_rproid   foreign key (proid) references project(proid);

    alter table pro_emp add constraint fk_rempid   foreign key (empid) references employee2(empid);

    不知什么原因,添加外键的sql 没有执行成功,直接在navicat中手动加了外键

    --查询

    select  * from project;

    select * from employee2;   

  • 相关阅读:
    Linux文件和目录管理常用重要命令
    Windows和Linux下Mysql 重置root 密码
    瀑布流vue-waterfall的高度设置
    vue-cli 引入axios及跨域使用
    Vue 脱坑记
    shell基础
    正则
    安装卸载
    压缩打包
    vim工具
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/9390725.html
Copyright © 2020-2023  润新知