Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Created February 18, 2020 07:22
Show Gist options
  • Save bastienapp/d6b8c9a18798519419d0931fca433ebd to your computer and use it in GitHub Desktop.
Save bastienapp/d6b8c9a18798519419d0931fca433ebd to your computer and use it in GitHub Desktop.
employee-add-fields.sql
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