Created
February 18, 2020 07:22
-
-
Save bastienapp/d6b8c9a18798519419d0931fca433ebd to your computer and use it in GitHub Desktop.
employee-add-fields.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE employee ADD COLUMN hired_year SMALLINT; | |
ALTER TABLE employee ADD COLUMN department ENUM('Marketing', 'HR', 'Software', 'Hardware'); | |
UPDATE employee SET hired_year = FLOOR(RAND()*(2019-2014+1)+2014); | |
UPDATE employee SET department = CASE | |
WHEN RAND() < 0.25 THEN 'Marketing' | |
WHEN RAND() < 0.33 THEN 'HR' | |
WHEN RAND() < 0.5 THEN 'Software' | |
ELSE 'Hardware' | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment