zoukankan      html  css  js  c++  java
  • 示例库

    employees库:Departments   dept_emp   dept_manager  employees  salaries   titles

    mysql> select * from departments limit 1;

    +---------+------------------+

    | dept_no | dept_name       

    +---------+------------------+

    | d009    | Customer Service

    +---------+------------------+


    mysql> select * from dept_emp limit 1;

    +--------+---------+------------+------------+

    | emp_no | dept_no | from_date  | to_date    |

    +--------+---------+------------+------------+

    |  10001 | d005    | 1986-06-26 | 9999-01-01 |

    +--------+---------+------------+------------+

    mysql> select * from dept_manager limit 1;

    +---------+--------+------------+------------+

    | dept_no | emp_no | from_date  | to_date    |

    +---------+--------+------------+------------+

    | d001    | 110022 | 1985-01-01 | 1991-10-01 |

    +---------+--------+------------+------------+

    mysql> select * from employees limit 1;

    +--------+------------+------------+-----------+--------+------------+

    | emp_no | birth_date | first_name | last_name | gender | hire_date  |

    +--------+------------+------------+-----------+--------+------------+

    |  10001 | 1953-09-02 | Georgi     | Facello   | M      | 1986-06-26 |

    +--------+------------+------------+-----------+--------+------------+

    mysql> select * from salaries limit 1;

    +--------+--------+------------+------------+

    | emp_no | salary | from_date  | to_date    |

    +--------+--------+------------+------------+

    |  10001 |  60117 | 1986-06-26 | 1987-06-26 |

    +--------+--------+------------+------------+

    mysql> select * from titles limit 1;

    +--------+-----------------+------------+------------+

    | emp_no | title           | from_date  | to_date    |

    +--------+-----------------+------------+------------+

    |  10001 | Senior Engineer | 1986-06-26 | 9999-01-01 |

    +--------+-----------------+------------+------------+

    Create Table :CREATE TABLE `departments` (

      `dept_no` char(4) NOT NULL,

      `dept_name` varchar(40) NOT NULL,

      PRIMARY KEY (`dept_no`),

      UNIQUE KEY `dept_name` (`dept_name`)

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

    Create Table: CREATE TABLE `dept_emp` (

      `emp_no` int(11) NOT NULL,

      `dept_no` char(4) NOT NULL,

      `from_date` date NOT NULL,

      `to_date` date NOT NULL,

      PRIMARY KEY (`emp_no`,`dept_no`),

      KEY `emp_no` (`emp_no`),

      KEY `dept_no` (`dept_no`),

      CONSTRAINT `dept_emp_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`)  ON DELETE CASCADE,

      CONSTRAINT `dept_emp_ibfk_2` FOREIGN KEY (`dept_no`) REFERENCES `departments`

    (`dept_no`) ON DELETE CASCADE

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

    Create Table: CREATE TABLE `dept_manager` (

      `dept_no` char(4) NOT NULL,

      `emp_no` int(11) NOT NULL,

      `from_date` date NOT NULL,

      `to_date` date NOT NULL,

      PRIMARY KEY (`emp_no`,`dept_no`),

      KEY `emp_no` (`emp_no`),

      KEY `dept_no` (`dept_no`),

      CONSTRAINT `dept_manager_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE,

      CONSTRAINT `dept_manager_ibfk_2` FOREIGN KEY (`dept_no`) REFERENCES `departments` (`dept_no`) ON DELETE CASCADE

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

    Create Table: CREATE TABLE `employees` (

      `emp_no` int(11) NOT NULL,

      `birth_date` date NOT NULL,

      `first_name` varchar(14) NOT NULL,

      `last_name` varchar(16) NOT NULL,

      `gender` enum('M','F') NOT NULL,

      `hire_date` date NOT NULL,

      PRIMARY KEY (`emp_no`)

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

    Create Table: CREATE TABLE `salaries` (

      `emp_no` int(11) NOT NULL,

      `salary` int(11) NOT NULL,

      `from_date` date NOT NULL,

      `to_date` date NOT NULL,

      PRIMARY KEY (`emp_no`,`from_date`),

      KEY `emp_no` (`emp_no`),

      CONSTRAINT `salaries_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

    Create Table: CREATE TABLE `titles` (

      `emp_no` int(11) NOT NULL,

      `title` varchar(50) NOT NULL,

      `from_date` date NOT NULL,

      `to_date` date DEFAULT NULL,

      PRIMARY KEY (`emp_no`,`title`,`from_date`),

      KEY `emp_no` (`emp_no`),

      CONSTRAINT `titles_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1

  • 相关阅读:
    立体匹配中宽基线与窄基线的定义
    基于MST的立体匹配及相关改进(A Non-Local Cost Aggregation Method for Stereo Matching)
    Object Removal by Exemplar-Based Inpainting 概括(附源码)
    使用matlab进行空间拟合
    C# 控件 DevExpress的DateEdit设置显示日期和时间
    C#获取当前程序运行路径的方法集合
    《Entity Framework 6 Recipes》中文翻译系列 (14) -----第三章 查询之查询中设置默认值和存储过程返回多结果集 (转)
    《Entity Framework 6 Recipes》中文翻译系列 (13) -----第三章 查询之使用Entity SQL
    《Entity Framework 6 Recipes》中文翻译系列 (12) -----第三章 查询之使用SQL语句 (转)
    《Entity Framework 6 Recipes》中文翻译系列 (11) -----第三章 查询之异步查询 (转)
  • 原文地址:https://www.cnblogs.com/z-ruhua/p/13658126.html
Copyright © 2011-2022 走看看