sidrs

22-7-2025

Jul 21st, 2025
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 29.94 KB | None | 0 0
  1. student@student:~$ sudo mysql
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 10
  4. Server version: 8.0.42-0ubuntu0.22.04.1 (Ubuntu)
  5.  
  6. Copyright (c) 2000, 2025, Oracle and/or its affiliates.
  7.  
  8. Oracle is a registered trademark of Oracle Corporation and/or its
  9. affiliates. Other names may be trademarks of their respective
  10. owners.
  11.  
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  13.  
  14. mysql> USE TCB53;
  15. Database changed
  16.  
  17. mysql> CREATE TABLE EmployeeInfo
  18.     -> (id int(5), name varchar(50), post varchar(50), salary int(5));
  19. Query OK, 0 rows affected, 2 warnings (0.78 sec)
  20.  
  21. mysql> INSERT INTO EmployeeInfo (id, name, post, salary) VALUES
  22.     -> (1, 'Alice Johnson', 'Software Engineer', 75000),
  23.     -> (2, 'Bob Smith', 'QA Engineer', 68000),
  24.     -> (3, 'Cathy Williams', 'Software Engineer', 75000),
  25.     -> (4, 'David Brown', 'UI/UX Designer', 72000),
  26.     -> (5, 'Ella Davis', 'Project Manager', 90000),
  27.     -> (6, 'Frank Wilson', 'Backend Developer', 77000),
  28.     -> (7, 'Grace Lee', 'Frontend Developer', 76000),
  29.     -> (8, 'Henry Clark', 'Software Engineer', 75000),
  30.     -> (9, 'Ivy Lewis', 'QA Engineer', 68000),
  31.     -> (10, 'Jake Hall', 'Intern', 30000),
  32.     -> (11, 'Karen Young', 'Project Manager', 90000),
  33.     -> (12, 'Leo King', 'Security Analyst', 85000),
  34.     -> (13, 'Mona Scott', 'Full Stack Developer', 82000),
  35.     -> (14, 'Nathan Adams', 'Scrum Master', 88000),
  36.     -> (15, 'Olivia Baker', 'Frontend Developer', 76000),
  37.     -> (16, 'Paul Turner', 'Cloud Architect', 98000),
  38.     -> (17, 'Queenie Allen', 'Machine Learning Engineer', 97000),
  39.     -> (18, 'Robert Hill', 'Backend Developer', 77000),
  40.     -> (19, 'Sara Green', 'QA Engineer', 68000),
  41.     -> (20, 'Tom Wright', 'Support Engineer', 65000);
  42. Query OK, 20 rows affected (0.20 sec)
  43. Records: 20  Duplicates: 0  Warnings: 0
  44.  
  45. mysql> DESC EmployeeInfo;
  46. +--------+-------------+------+-----+---------+-------+
  47. | Field  | Type        | Null | Key | Default | Extra |
  48. +--------+-------------+------+-----+---------+-------+
  49. | id     | int         | YES  |     | NULL    |       |
  50. | name   | varchar(50) | YES  |     | NULL    |       |
  51. | post   | varchar(50) | YES  |     | NULL    |       |
  52. | salary | int         | YES  |     | NULL    |       |
  53. +--------+-------------+------+-----+---------+-------+
  54. 4 rows in set (0.48 sec)
  55.  
  56. mysql> SELECT * FROM EmployeeInfo;
  57. +------+----------------+---------------------------+--------+
  58. | id   | name           | post                      | salary |
  59. +------+----------------+---------------------------+--------+
  60. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  61. |    2 | Bob Smith      | QA Engineer               |  68000 |
  62. |    3 | Cathy Williams | Software Engineer         |  75000 |
  63. |    4 | David Brown    | UI/UX Designer            |  72000 |
  64. |    5 | Ella Davis     | Project Manager           |  90000 |
  65. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  66. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  67. |    8 | Henry Clark    | Software Engineer         |  75000 |
  68. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  69. |   10 | Jake Hall      | Intern                    |  30000 |
  70. |   11 | Karen Young    | Project Manager           |  90000 |
  71. |   12 | Leo King       | Security Analyst          |  85000 |
  72. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  73. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  74. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  75. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  76. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  77. |   18 | Robert Hill    | Backend Developer         |  77000 |
  78. |   19 | Sara Green     | QA Engineer               |  68000 |
  79. |   20 | Tom Wright     | Support Engineer          |  65000 |
  80. +------+----------------+---------------------------+--------+
  81. 20 rows in set (0.00 sec)
  82.  
  83. mysql> DELETE FROM EmployeeInfo WHERE id = 19
  84.     -> ;
  85. Query OK, 1 row affected (0.09 sec)
  86.  
  87. mysql> SELECT * FROM EmployeeInfo
  88.     -> ;
  89. +------+----------------+---------------------------+--------+
  90. | id   | name           | post                      | salary |
  91. +------+----------------+---------------------------+--------+
  92. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  93. |    2 | Bob Smith      | QA Engineer               |  68000 |
  94. |    3 | Cathy Williams | Software Engineer         |  75000 |
  95. |    4 | David Brown    | UI/UX Designer            |  72000 |
  96. |    5 | Ella Davis     | Project Manager           |  90000 |
  97. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  98. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  99. |    8 | Henry Clark    | Software Engineer         |  75000 |
  100. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  101. |   10 | Jake Hall      | Intern                    |  30000 |
  102. |   11 | Karen Young    | Project Manager           |  90000 |
  103. |   12 | Leo King       | Security Analyst          |  85000 |
  104. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  105. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  106. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  107. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  108. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  109. |   18 | Robert Hill    | Backend Developer         |  77000 |
  110. |   20 | Tom Wright     | Support Engineer          |  65000 |
  111. +------+----------------+---------------------------+--------+
  112. 19 rows in set (0.00 sec)
  113.  
  114. mysql> INSERT INTO EmployeeInfo(id, name, post, salaray) VALUES (19, John Doe, Intern, 30000);
  115. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Doe, Intern, 30000)' at line 1
  116.  
  117. mysql> INSERT INTO EmployeeInfo(id, name, post, salary) VALUES(19, 'John Doe', 'Intern', 30000);
  118. Query OK, 1 row affected (0.06 sec)
  119.  
  120. mysql> SELECT * FROM EmployeeInfo
  121.     -> ;
  122. +------+----------------+---------------------------+--------+
  123. | id   | name           | post                      | salary |
  124. +------+----------------+---------------------------+--------+
  125. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  126. |    2 | Bob Smith      | QA Engineer               |  68000 |
  127. |    3 | Cathy Williams | Software Engineer         |  75000 |
  128. |    4 | David Brown    | UI/UX Designer            |  72000 |
  129. |    5 | Ella Davis     | Project Manager           |  90000 |
  130. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  131. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  132. |    8 | Henry Clark    | Software Engineer         |  75000 |
  133. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  134. |   10 | Jake Hall      | Intern                    |  30000 |
  135. |   11 | Karen Young    | Project Manager           |  90000 |
  136. |   12 | Leo King       | Security Analyst          |  85000 |
  137. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  138. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  139. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  140. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  141. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  142. |   18 | Robert Hill    | Backend Developer         |  77000 |
  143. |   20 | Tom Wright     | Support Engineer          |  65000 |
  144. |   19 | John Doe       | Intern                    |  30000 |
  145. +------+----------------+---------------------------+--------+
  146. 20 rows in set (0.00 sec)
  147.  
  148. mysql> SELECT * FROM EmployeeInfo
  149.     -> ;
  150. +------+----------------+---------------------------+--------+
  151. | id   | name           | post                      | salary |
  152. +------+----------------+---------------------------+--------+
  153. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  154. |    2 | Bob Smith      | QA Engineer               |  68000 |
  155. |    3 | Cathy Williams | Software Engineer         |  75000 |
  156. |    4 | David Brown    | UI/UX Designer            |  72000 |
  157. |    5 | Ella Davis     | Project Manager           |  90000 |
  158. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  159. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  160. |    8 | Henry Clark    | Software Engineer         |  75000 |
  161. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  162. |   10 | Jake Hall      | Intern                    |  30000 |
  163. |   11 | Karen Young    | Project Manager           |  90000 |
  164. |   12 | Leo King       | Security Analyst          |  85000 |
  165. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  166. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  167. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  168. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  169. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  170. |   18 | Robert Hill    | Backend Developer         |  77000 |
  171. |   20 | Tom Wright     | Support Engineer          |  65000 |
  172. |   19 | John Doe       | Intern                    |  30000 |
  173. +------+----------------+---------------------------+--------+
  174. 20 rows in set (0.00 sec)
  175.  
  176. mysql> SELECT * FROM EmployeeInfo;
  177. +------+----------------+---------------------------+--------+
  178. | id   | name           | post                      | salary |
  179. +------+----------------+---------------------------+--------+
  180. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  181. |    2 | Bob Smith      | QA Engineer               |  68000 |
  182. |    3 | Cathy Williams | Software Engineer         |  75000 |
  183. |    4 | David Brown    | UI/UX Designer            |  72000 |
  184. |    5 | Ella Davis     | Project Manager           |  90000 |
  185. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  186. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  187. |    8 | Henry Clark    | Software Engineer         |  75000 |
  188. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  189. |   10 | Jake Hall      | Intern                    |  30000 |
  190. |   11 | Karen Young    | Project Manager           |  90000 |
  191. |   12 | Leo King       | Security Analyst          |  85000 |
  192. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  193. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  194. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  195. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  196. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  197. |   18 | Robert Hill    | Backend Developer         |  77000 |
  198. |   20 | Tom Wright     | Support Engineer          |  65000 |
  199. |   19 | John Doe       | Intern                    |  30000 |
  200. +------+----------------+---------------------------+--------+
  201. 20 rows in set (0.00 sec)
  202.  
  203. mysql> SELECT * FROM EmployeeInfo;
  204. +------+----------------+---------------------------+--------+
  205. | id   | name           | post                      | salary |
  206. +------+----------------+---------------------------+--------+
  207. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  208. |    2 | Bob Smith      | QA Engineer               |  68000 |
  209. |    3 | Cathy Williams | Software Engineer         |  75000 |
  210. |    4 | David Brown    | UI/UX Designer            |  72000 |
  211. |    5 | Ella Davis     | Project Manager           |  90000 |
  212. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  213. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  214. |    8 | Henry Clark    | Software Engineer         |  75000 |
  215. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  216. |   10 | Jake Hall      | Intern                    |  30000 |
  217. |   11 | Karen Young    | Project Manager           |  90000 |
  218. |   12 | Leo King       | Security Analyst          |  85000 |
  219. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  220. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  221. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  222. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  223. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  224. |   18 | Robert Hill    | Backend Developer         |  77000 |
  225. |   20 | Tom Wright     | Support Engineer          |  65000 |
  226. |   19 | John Doe       | Intern                    |  30000 |
  227. +------+----------------+---------------------------+--------+
  228. 20 rows in set (0.00 sec)
  229.  
  230. mysql> UPDATE EmployeeInfo SET id = 19 WHERE name = 'Tom Wright';
  231. Query OK, 1 row affected (0.06 sec)
  232. Rows matched: 1  Changed: 1  Warnings: 0
  233.  
  234. mysql> SELECT * FROM EmployeeInfo;
  235. +------+----------------+---------------------------+--------+
  236. | id   | name           | post                      | salary |
  237. +------+----------------+---------------------------+--------+
  238. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  239. |    2 | Bob Smith      | QA Engineer               |  68000 |
  240. |    3 | Cathy Williams | Software Engineer         |  75000 |
  241. |    4 | David Brown    | UI/UX Designer            |  72000 |
  242. |    5 | Ella Davis     | Project Manager           |  90000 |
  243. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  244. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  245. |    8 | Henry Clark    | Software Engineer         |  75000 |
  246. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  247. |   10 | Jake Hall      | Intern                    |  30000 |
  248. |   11 | Karen Young    | Project Manager           |  90000 |
  249. |   12 | Leo King       | Security Analyst          |  85000 |
  250. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  251. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  252. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  253. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  254. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  255. |   18 | Robert Hill    | Backend Developer         |  77000 |
  256. |   19 | Tom Wright     | Support Engineer          |  65000 |
  257. |   19 | John Doe       | Intern                    |  30000 |
  258. +------+----------------+---------------------------+--------+
  259. 20 rows in set (0.00 sec)
  260.  
  261. mysql> UPDATE EmployeeInfo SET id = 19 WHERE name = 'John Doe';
  262. Query OK, 0 rows affected (0.00 sec)
  263. Rows matched: 1  Changed: 0  Warnings: 0
  264.  
  265. mysql> SELECT * FROM EmployeeInfo;
  266. +------+----------------+---------------------------+--------+
  267. | id   | name           | post                      | salary |
  268. +------+----------------+---------------------------+--------+
  269. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  270. |    2 | Bob Smith      | QA Engineer               |  68000 |
  271. |    3 | Cathy Williams | Software Engineer         |  75000 |
  272. |    4 | David Brown    | UI/UX Designer            |  72000 |
  273. |    5 | Ella Davis     | Project Manager           |  90000 |
  274. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  275. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  276. |    8 | Henry Clark    | Software Engineer         |  75000 |
  277. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  278. |   10 | Jake Hall      | Intern                    |  30000 |
  279. |   11 | Karen Young    | Project Manager           |  90000 |
  280. |   12 | Leo King       | Security Analyst          |  85000 |
  281. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  282. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  283. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  284. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  285. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  286. |   18 | Robert Hill    | Backend Developer         |  77000 |
  287. |   19 | Tom Wright     | Support Engineer          |  65000 |
  288. |   19 | John Doe       | Intern                    |  30000 |
  289. +------+----------------+---------------------------+--------+
  290. 20 rows in set (0.00 sec)
  291.  
  292. mysql> UPDATE EmployeeInfo SET id = 20 WHERE name = 'John Doe';
  293. Query OK, 1 row affected (0.04 sec)
  294. Rows matched: 1  Changed: 1  Warnings: 0
  295.  
  296. mysql> SELECT * FROM EmployeeInfo;
  297. +------+----------------+---------------------------+--------+
  298. | id   | name           | post                      | salary |
  299. +------+----------------+---------------------------+--------+
  300. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  301. |    2 | Bob Smith      | QA Engineer               |  68000 |
  302. |    3 | Cathy Williams | Software Engineer         |  75000 |
  303. |    4 | David Brown    | UI/UX Designer            |  72000 |
  304. |    5 | Ella Davis     | Project Manager           |  90000 |
  305. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  306. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  307. |    8 | Henry Clark    | Software Engineer         |  75000 |
  308. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  309. |   10 | Jake Hall      | Intern                    |  30000 |
  310. |   11 | Karen Young    | Project Manager           |  90000 |
  311. |   12 | Leo King       | Security Analyst          |  85000 |
  312. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  313. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  314. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  315. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  316. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  317. |   18 | Robert Hill    | Backend Developer         |  77000 |
  318. |   19 | Tom Wright     | Support Engineer          |  65000 |
  319. |   20 | John Doe       | Intern                    |  30000 |
  320. +------+----------------+---------------------------+--------+
  321. 20 rows in set (0.00 sec)
  322.  
  323. mysql> INSERT INTO EmployeeInfo (id, name, post, salary) VALUES (21, 'James L', 'Jr. Engineer', 35000);
  324. Query OK, 1 row affected (0.06 sec)
  325.  
  326. mysql> SELECT * FROM EmployeeInfo;
  327. +------+----------------+---------------------------+--------+
  328. | id   | name           | post                      | salary |
  329. +------+----------------+---------------------------+--------+
  330. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  331. |    2 | Bob Smith      | QA Engineer               |  68000 |
  332. |    3 | Cathy Williams | Software Engineer         |  75000 |
  333. |    4 | David Brown    | UI/UX Designer            |  72000 |
  334. |    5 | Ella Davis     | Project Manager           |  90000 |
  335. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  336. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  337. |    8 | Henry Clark    | Software Engineer         |  75000 |
  338. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  339. |   10 | Jake Hall      | Intern                    |  30000 |
  340. |   11 | Karen Young    | Project Manager           |  90000 |
  341. |   12 | Leo King       | Security Analyst          |  85000 |
  342. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  343. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  344. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  345. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  346. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  347. |   18 | Robert Hill    | Backend Developer         |  77000 |
  348. |   19 | Tom Wright     | Support Engineer          |  65000 |
  349. |   20 | John Doe       | Intern                    |  30000 |
  350. |   21 | James L        | Jr. Engineer              |  35000 |
  351. +------+----------------+---------------------------+--------+
  352. 21 rows in set (0.00 sec)
  353.  
  354. mysql> DELETE FROM EmployeeInfo WHERE id = '21'
  355.     -> ;
  356. Query OK, 1 row affected (0.14 sec)
  357.  
  358. mysql> SELECT * FROM EmployeeInfo;
  359. +------+----------------+---------------------------+--------+
  360. | id   | name           | post                      | salary |
  361. +------+----------------+---------------------------+--------+
  362. |    1 | Alice Johnson  | Software Engineer         |  75000 |
  363. |    2 | Bob Smith      | QA Engineer               |  68000 |
  364. |    3 | Cathy Williams | Software Engineer         |  75000 |
  365. |    4 | David Brown    | UI/UX Designer            |  72000 |
  366. |    5 | Ella Davis     | Project Manager           |  90000 |
  367. |    6 | Frank Wilson   | Backend Developer         |  77000 |
  368. |    7 | Grace Lee      | Frontend Developer        |  76000 |
  369. |    8 | Henry Clark    | Software Engineer         |  75000 |
  370. |    9 | Ivy Lewis      | QA Engineer               |  68000 |
  371. |   10 | Jake Hall      | Intern                    |  30000 |
  372. |   11 | Karen Young    | Project Manager           |  90000 |
  373. |   12 | Leo King       | Security Analyst          |  85000 |
  374. |   13 | Mona Scott     | Full Stack Developer      |  82000 |
  375. |   14 | Nathan Adams   | Scrum Master              |  88000 |
  376. |   15 | Olivia Baker   | Frontend Developer        |  76000 |
  377. |   16 | Paul Turner    | Cloud Architect           |  98000 |
  378. |   17 | Queenie Allen  | Machine Learning Engineer |  97000 |
  379. |   18 | Robert Hill    | Backend Developer         |  77000 |
  380. |   19 | Tom Wright     | Support Engineer          |  65000 |
  381. |   20 | John Doe       | Intern                    |  30000 |
  382. +------+----------------+---------------------------+--------+
  383. 20 rows in set (0.00 sec)
  384.  
  385. mysql> CREATE TABLE Departments (
  386.     -> depid INT,
  387.     -> dept varchar(50)
  388.     -> );
  389. Query OK, 0 rows affected (4.47 sec)
  390.  
  391. mysql> DESC TABLE Departments;
  392. +----+-------------+-------------+------------+------+---------------+------+---------+------+------+----------+-------+
  393. | id | select_type | table       | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
  394. +----+-------------+-------------+------------+------+---------------+------+---------+------+------+----------+-------+
  395. |  1 | SIMPLE      | Departments | NULL       | ALL  | NULL          | NULL | NULL    | NULL |    1 |   100.00 | NULL  |
  396. +----+-------------+-------------+------------+------+---------------+------+---------+------+------+----------+-------+
  397. 1 row in set, 1 warning (0.59 sec)
  398.  
  399. mysql> DESC Departments;
  400. +-------+-------------+------+-----+---------+-------+
  401. | Field | Type        | Null | Key | Default | Extra |
  402. +-------+-------------+------+-----+---------+-------+
  403. | depid | int         | YES  |     | NULL    |       |
  404. | dept  | varchar(50) | YES  |     | NULL    |       |
  405. +-------+-------------+------+-----+---------+-------+
  406. 2 rows in set (0.23 sec)
  407.  
  408. mysql> clear
  409.  
  410. mysql> INSERT INTO Departments (depid, dept) VALUES (1, 'Engineering'), (2, 'Human Resources'), (3, 'Product'), (4, 'Support');
  411. Query OK, 4 rows affected (0.24 sec)
  412. Records: 4  Duplicates: 0  Warnings: 0
  413.  
  414. mysql> SELECT * FROM Departments
  415.     -> ;
  416. +-------+-----------------+
  417. | depid | dept            |
  418. +-------+-----------------+
  419. |     1 | Engineering     |
  420. |     2 | Human Resources |
  421. |     3 | Product         |
  422. |     4 | Support         |
  423. +-------+-----------------+
  424. 4 rows in set (0.00 sec)
  425.  
  426. mysql> SELECT e.name, e.post, d.dept
  427.     -> FROM EmployeeInfo e
  428.     -> CROSS JOIN Departments d;
  429. +----------------+---------------------------+-----------------+
  430. | name           | post                      | dept            |
  431. +----------------+---------------------------+-----------------+
  432. | Alice Johnson  | Software Engineer         | Support         |
  433. | Alice Johnson  | Software Engineer         | Product         |
  434. | Alice Johnson  | Software Engineer         | Human Resources |
  435. | Alice Johnson  | Software Engineer         | Engineering     |
  436. | Bob Smith      | QA Engineer               | Support         |
  437. | Bob Smith      | QA Engineer               | Product         |
  438. | Bob Smith      | QA Engineer               | Human Resources |
  439. | Bob Smith      | QA Engineer               | Engineering     |
  440. | Cathy Williams | Software Engineer         | Support         |
  441. | Cathy Williams | Software Engineer         | Product         |
  442. | Cathy Williams | Software Engineer         | Human Resources |
  443. | Cathy Williams | Software Engineer         | Engineering     |
  444. | David Brown    | UI/UX Designer            | Support         |
  445. | David Brown    | UI/UX Designer            | Product         |
  446. | David Brown    | UI/UX Designer            | Human Resources |
  447. | David Brown    | UI/UX Designer            | Engineering     |
  448. | Ella Davis     | Project Manager           | Support         |
  449. | Ella Davis     | Project Manager           | Product         |
  450. | Ella Davis     | Project Manager           | Human Resources |
  451. | Ella Davis     | Project Manager           | Engineering     |
  452. | Frank Wilson   | Backend Developer         | Support         |
  453. | Frank Wilson   | Backend Developer         | Product         |
  454. | Frank Wilson   | Backend Developer         | Human Resources |
  455. | Frank Wilson   | Backend Developer         | Engineering     |
  456. | Grace Lee      | Frontend Developer        | Support         |
  457. | Grace Lee      | Frontend Developer        | Product         |
  458. | Grace Lee      | Frontend Developer        | Human Resources |
  459. | Grace Lee      | Frontend Developer        | Engineering     |
  460. | Henry Clark    | Software Engineer         | Support         |
  461. | Henry Clark    | Software Engineer         | Product         |
  462. | Henry Clark    | Software Engineer         | Human Resources |
  463. | Henry Clark    | Software Engineer         | Engineering     |
  464. | Ivy Lewis      | QA Engineer               | Support         |
  465. | Ivy Lewis      | QA Engineer               | Product         |
  466. | Ivy Lewis      | QA Engineer               | Human Resources |
  467. | Ivy Lewis      | QA Engineer               | Engineering     |
  468. | Jake Hall      | Intern                    | Support         |
  469. | Jake Hall      | Intern                    | Product         |
  470. | Jake Hall      | Intern                    | Human Resources |
  471. | Jake Hall      | Intern                    | Engineering     |
  472. | Karen Young    | Project Manager           | Support         |
  473. | Karen Young    | Project Manager           | Product         |
  474. | Karen Young    | Project Manager           | Human Resources |
  475. | Karen Young    | Project Manager           | Engineering     |
  476. | Leo King       | Security Analyst          | Support         |
  477. | Leo King       | Security Analyst          | Product         |
  478. | Leo King       | Security Analyst          | Human Resources |
  479. | Leo King       | Security Analyst          | Engineering     |
  480. | Mona Scott     | Full Stack Developer      | Support         |
  481. | Mona Scott     | Full Stack Developer      | Product         |
  482. | Mona Scott     | Full Stack Developer      | Human Resources |
  483. | Mona Scott     | Full Stack Developer      | Engineering     |
  484. | Nathan Adams   | Scrum Master              | Support         |
  485. | Nathan Adams   | Scrum Master              | Product         |
  486. | Nathan Adams   | Scrum Master              | Human Resources |
  487. | Nathan Adams   | Scrum Master              | Engineering     |
  488. | Olivia Baker   | Frontend Developer        | Support         |
  489. | Olivia Baker   | Frontend Developer        | Product         |
  490. | Olivia Baker   | Frontend Developer        | Human Resources |
  491. | Olivia Baker   | Frontend Developer        | Engineering     |
  492. | Paul Turner    | Cloud Architect           | Support         |
  493. | Paul Turner    | Cloud Architect           | Product         |
  494. | Paul Turner    | Cloud Architect           | Human Resources |
  495. | Paul Turner    | Cloud Architect           | Engineering     |
  496. | Queenie Allen  | Machine Learning Engineer | Support         |
  497. | Queenie Allen  | Machine Learning Engineer | Product         |
  498. | Queenie Allen  | Machine Learning Engineer | Human Resources |
  499. | Queenie Allen  | Machine Learning Engineer | Engineering     |
  500. | Robert Hill    | Backend Developer         | Support         |
  501. | Robert Hill    | Backend Developer         | Product         |
  502. | Robert Hill    | Backend Developer         | Human Resources |
  503. | Robert Hill    | Backend Developer         | Engineering     |
  504. | Tom Wright     | Support Engineer          | Support         |
  505. | Tom Wright     | Support Engineer          | Product         |
  506. | Tom Wright     | Support Engineer          | Human Resources |
  507. | Tom Wright     | Support Engineer          | Engineering     |
  508. | John Doe       | Intern                    | Support         |
  509. | John Doe       | Intern                    | Product         |
  510. | John Doe       | Intern                    | Human Resources |
  511. | John Doe       | Intern                    | Engineering     |
  512. +----------------+---------------------------+-----------------+
  513. 80 rows in set (0.03 sec)
  514.  
  515. mysql> CREATE VIEW NoSalary AS
  516.     -> SELECT id, name, post FROM EmployeeInfo;
  517. Query OK, 0 rows affected (0.18 sec)
  518.  
  519. mysql> Select * FROM NoSalary'
  520.    '> ^C
  521. mysql> Select * FROM NoSalary;
  522. +------+----------------+---------------------------+
  523. | id   | name           | post                      |
  524. +------+----------------+---------------------------+
  525. |    1 | Alice Johnson  | Software Engineer         |
  526. |    2 | Bob Smith      | QA Engineer               |
  527. |    3 | Cathy Williams | Software Engineer         |
  528. |    4 | David Brown    | UI/UX Designer            |
  529. |    5 | Ella Davis     | Project Manager           |
  530. |    6 | Frank Wilson   | Backend Developer         |
  531. |    7 | Grace Lee      | Frontend Developer        |
  532. |    8 | Henry Clark    | Software Engineer         |
  533. |    9 | Ivy Lewis      | QA Engineer               |
  534. |   10 | Jake Hall      | Intern                    |
  535. |   11 | Karen Young    | Project Manager           |
  536. |   12 | Leo King       | Security Analyst          |
  537. |   13 | Mona Scott     | Full Stack Developer      |
  538. |   14 | Nathan Adams   | Scrum Master              |
  539. |   15 | Olivia Baker   | Frontend Developer        |
  540. |   16 | Paul Turner    | Cloud Architect           |
  541. |   17 | Queenie Allen  | Machine Learning Engineer |
  542. |   18 | Robert Hill    | Backend Developer         |
  543. |   19 | Tom Wright     | Support Engineer          |
  544. |   20 | John Doe       | Intern                    |
  545. +------+----------------+---------------------------+
  546. 20 rows in set (0.02 sec)
  547.  
  548. mysql> SELECT AVG(salary) AS average_salary FROM EmployeeInfo;
  549. +----------------+
  550. | average_salary |
  551. +----------------+
  552. |     74700.0000 |
  553. +----------------+
  554. 1 row in set (0.03 sec)
  555.  
  556. mysql> SELECT AVG(salary) AS average_developer_salary FROM EmployeeInfo WHERE post LIKE '%Developer';
  557. +--------------------------+
  558. | average_developer_salary |
  559. +--------------------------+
  560. |               77600.0000 |
  561. +--------------------------+
  562. 1 row in set (0.03 sec)
  563.  
  564.  
Advertisement
Add Comment
Please, Sign In to add comment