WRITE SQL CODE Q.1. System Variables System variables can be set via the command
ID: 3715642 • Letter: W
Question
WRITE SQL CODE
Q.1. System Variables
System variables can be set via the command line. Please write a sequence of statements to:
- Set safe updates to false for the session.
- Do the following at the global level: o Set the maximum number of connections to 45.
o Set the threshold for long running queries to 7 seconds – do this at the global level.
o Set logs to expire when they are more than 3 days old
Write the commands to display the value of the four variables you have updated.
Q.2. Managing Users
Write statements that do the following:
- Create users as follows: o Create user daisy with password imadog
o Create user elmo with password imacat
o Create user ap_superuser with password imsuper
o Create user ap_dev with password apdev
o Create user ap_guest with password apuser
- Rename user daisy to have username lazydaisy
- Change password for daisy to be imalazydog
- Drop user elmo
Explanation / Answer
SET GLOBAL long_query_time = 7;
SET GLOBAL expire_logs_days = 3
b)
CREATE USER 'elmo' IDENTIFIED BY 'imacat';
CREATE USER 'ap_superuser' IDENTIFIED BY 'imsuper';
CREATE USER 'ap_dev' IDENTIFIED BY 'apdev';
CREATE USER 'ap_guest' IDENTIFIED BY 'apuser';
UPDATE user SET user='lazydiasy' WHERE User = 'daisy';
UPDATE user SET password=PASSWORD('iamalazydog') where User='daisy';
DROP USER elmo
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.