DB笔记

Feb 26, 2019


SQL


BASIC


Logical Operators


SELECT * FROM VACATION;

  LASTNAME    EMPLOYEENUM   YEARS   LEAVETAKEN
  --------    -----------   -----   ----------
  ABLE        101           2       4
  BLEDSOE     107           8       45
  BOLD        210           15      100

Suppose each employee has 12 days of leave each year, now find all the employees whose names start with B and who have more than 50 days of leave coming.

    SELECT LASTNAME,
    YEARS * 12 - LEAVETAKEN REMAING
    FROM VACATIION
    WHERE LASTNAME LIKE 'B%'
    AND
    YEARS * 12 - LEAVETAKEN > 50
  
  
    LASTNAME        REMAINING
    --------        ----------
    BLEDSOE         51
    BOLD            80


MySql


workbench


使用workbench创建table还是很方便的,但是一直存在一个蛋疼的bug,如下图:

db_0


Auto Increment这个选项一直是勾选不了的,这就导致设置不了主键id自增,解决办法是在apply后,修改sql命令,手动添加AUTO_INCREMENT