SQL   121

MariaDB monitor

Guest on 25th November 2021 08:18:25 AM

  1. Microsoft Windows [Version 10.0.19041.1348]
  2. (c) Microsoft Corporation. ALL rights reserved.
  3.  
  4. C:\Users\Lenovo>mesql -uroot
  5. 'mesql' IS NOT recognized AS an internal OR external command,
  6. operable program OR batch file.
  7.  
  8. C:\Users\Lenovo>mysql -uroot
  9. Welcome TO the MariaDB monitor.  Commands END WITH ; OR \g.
  10. Your MariaDB connection id IS 9
  11. Server version: 10.4.21-MariaDB mariadb.org BINARY distribution
  12.  
  13. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab AND others.
  14.  
  15. TYPE 'help;' OR '\h' FOR help. TYPE '\c' TO clear the CURRENT INPUT statement.
  16.  
  17. MariaDB [(NONE)]> CREATE TABLE Triangles (
  18.     ->     id INT(6) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  19.     ->     Side_1 DECIMAL(5,2) NOT NULL DEFAULT 0,
  20.     ->     Side_2 DECIMAL(5,2) NOT NULL DEFAULT 0,
  21.     ->     Side_3 DECIMAL(5,2) NOT NULL DEFAULT 0
  22.     ->     );
  23. ERROR 1046 (3D000): No DATABASE selected
  24. MariaDB [(NONE)]> USE cont
  25. DATABASE changed
  26. MariaDB [cont]> DROP triangles
  27.     -> ;
  28. ERROR 1064 (42000): You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MariaDB server version FOR the RIGHT syntax TO USE near 'triangles' at line 1
  29. MariaDB [cont]> DROP TABLE triangles;
  30. Query OK, 0 ROWS affected (0.012 sec)
  31.  
  32. MariaDB [cont]> CREATE TABLE Triangles (
  33.     ->     id INT(6) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  34.     ->     Side_1 DECIMAL(5,2) NOT NULL DEFAULT 0,
  35.     ->     Side_2 DECIMAL(5,2) NOT NULL DEFAULT 0,
  36.     ->     Side_3 DECIMAL(5,2) NOT NULL DEFAULT 0
  37.     ->     );
  38. Query OK, 0 ROWS affected (0.016 sec)
  39.  
  40. MariaDB [cont]> CREATE TABLE Types (
  41.     ->     id INT(4) NOT NULL  PRIMARY KEY,
  42.     ->     kind VARCHAR(16) NOT NULL
  43.     ->     );
  44. ERROR 1050 (42S01): TABLE 'types' already EXISTS
  45. MariaDB [cont]> DROP TABLE types;
  46. Query OK, 0 ROWS affected (0.008 sec)
  47.  
  48. MariaDB [cont]> CREATE TABLE Types (
  49.     ->     id INT(4) NOT NULL  PRIMARY KEY,
  50.     ->     kind VARCHAR(16) NOT NULL
  51.     ->     );
  52. Query OK, 0 ROWS affected (0.016 sec)
  53.  
  54. MariaDB [cont]> INSERT INTO Triangles(id,side_1,side_2,side_3)
  55.     -> VALUES(1,10.0,20.0,30.0),
  56.     -> (2,20.0,10.0,20.0),
  57.     -> (3,20.0,20.0,20.0),
  58.     -> (4,30.0,50.0,40.0);
  59. Query OK, 4 ROWS affected (0.009 sec)
  60. Records: 4  Duplicates: 0  Warnings: 0
  61.  
  62. MariaDB [cont]>
  63. MariaDB [cont]> INSERT INTO Triangles(id,side_1,side_2,side_3)
  64.     -> VALUES(5,(RAND()*(200-10+1))+10,(RAND()*(200-10+1))+10,(RAND()*(200-10+1))+10);
  65. Query OK, 1 ROW affected, 3 warnings (0.007 sec)
  66.  
  67. MariaDB [cont]>
  68. MariaDB [cont]> INSERT INTO Triangles(id,side_1,side_2,side_3)
  69.     -> VALUES(5,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10);
  70. ERROR 1062 (23000): Duplicate entry '5' FOR KEY 'PRIMARY'
  71. MariaDB [cont]> VALUES(6,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10);
  72. +---+----------------------+----------------------+----------------------+
  73. | 6 | RAND()*(200-10+1)+10 | RAND()*(200-10+1)+10 | RAND()*(200-10+1)+10 |
  74. +---+----------------------+----------------------+----------------------+
  75. | 6 |    84.71924942333182 |   31.484210223410475 |    84.26330871718312 |
  76. +---+----------------------+----------------------+----------------------+
  77. 1 ROW IN SET (0.006 sec)
  78.  
  79. MariaDB [cont]>
  80. MariaDB [cont]> INSERT INTO Triangles(side_1,side_2,side_3)
  81.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  82.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  83.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  84.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  85.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  86.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  87.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  88.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  89.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  90.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  91.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  92.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  93.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  94.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  95.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  96.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  97.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  98.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  99.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  100.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  101.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10);
  102. ERROR 1064 (42000): You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MariaDB server version FOR the RIGHT syntax TO USE near 'values(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  103. value...' at line 3
  104. MariaDB [cont]> INSERT INTO Triangles(side_1,side_2,side_3)
  105.     -> VALUES(RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  106.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  107.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  108.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  109.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  110.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  111.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  112.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  113.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  114.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  115.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  116.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  117.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  118.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  119.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  120.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  121.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  122.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  123.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  124.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  125.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10),
  126.     -> (RAND()*(200-10+1)+10,RAND()*(200-10+1)+10,RAND()*(200-10+1)+10);
  127. Query OK, 22 ROWS affected, 66 warnings (0.007 sec)
  128. Records: 22  Duplicates: 0  Warnings: 66
  129.  
  130. MariaDB [cont]> SELECT * FROM triangles;
  131. +----+--------+--------+--------+
  132. | id | Side_1 | Side_2 | Side_3 |
  133. +----+--------+--------+--------+
  134. |  1 |  10.00 |  20.00 |  30.00 |
  135. |  2 |  20.00 |  10.00 |  20.00 |
  136. |  3 |  20.00 |  20.00 |  20.00 |
  137. |  4 |  30.00 |  50.00 |  40.00 |
  138. |  5 |  74.61 | 145.59 | 112.14 |
  139. |  6 | 125.86 | 175.53 | 108.06 |
  140. |  7 | 194.69 |  66.30 | 119.42 |
  141. |  8 | 197.20 |  44.74 | 195.10 |
  142. |  9 |  67.29 | 123.15 |  21.88 |
  143. | 10 | 111.93 | 102.01 | 164.27 |
  144. | 11 | 123.30 | 113.72 | 188.70 |
  145. | 12 |  19.33 |  93.56 |  17.80 |
  146. | 13 | 180.31 |  74.18 |  10.95 |
  147. | 14 |  13.22 |  23.24 |  66.54 |
  148. | 15 |  62.00 | 100.37 | 114.85 |
  149. | 16 |  72.13 | 197.12 | 186.19 |
  150. | 17 | 138.61 | 124.46 | 196.46 |
  151. | 18 |  25.92 | 103.25 |  46.48 |
  152. | 19 | 103.63 | 177.71 | 185.67 |
  153. | 20 | 194.23 |  22.11 |  90.88 |
  154. | 21 | 187.08 |  79.77 |  18.59 |
  155. | 22 |  34.67 | 107.54 |  41.72 |
  156. | 23 |  66.97 | 199.68 |  23.52 |
  157. | 24 |  81.53 | 136.12 |  44.00 |
  158. | 25 | 183.63 |  12.17 |  72.96 |
  159. | 26 | 127.29 |  25.55 | 117.89 |
  160. | 27 | 120.79 |  49.30 |  65.12 |
  161. +----+--------+--------+--------+
  162. 27 ROWS IN SET (0.000 sec)
  163.  
  164. MariaDB [cont]> SELECT * FROM triangles ORDER BY side_1 ASC;
  165. +----+--------+--------+--------+
  166. | id | Side_1 | Side_2 | Side_3 |
  167. +----+--------+--------+--------+
  168. |  1 |  10.00 |  20.00 |  30.00 |
  169. | 14 |  13.22 |  23.24 |  66.54 |
  170. | 12 |  19.33 |  93.56 |  17.80 |
  171. |  3 |  20.00 |  20.00 |  20.00 |
  172. |  2 |  20.00 |  10.00 |  20.00 |
  173. | 18 |  25.92 | 103.25 |  46.48 |
  174. |  4 |  30.00 |  50.00 |  40.00 |
  175. | 22 |  34.67 | 107.54 |  41.72 |
  176. | 15 |  62.00 | 100.37 | 114.85 |
  177. | 23 |  66.97 | 199.68 |  23.52 |
  178. |  9 |  67.29 | 123.15 |  21.88 |
  179. | 16 |  72.13 | 197.12 | 186.19 |
  180. |  5 |  74.61 | 145.59 | 112.14 |
  181. | 24 |  81.53 | 136.12 |  44.00 |
  182. | 19 | 103.63 | 177.71 | 185.67 |
  183. | 10 | 111.93 | 102.01 | 164.27 |
  184. | 27 | 120.79 |  49.30 |  65.12 |
  185. | 11 | 123.30 | 113.72 | 188.70 |
  186. |  6 | 125.86 | 175.53 | 108.06 |
  187. | 26 | 127.29 |  25.55 | 117.89 |
  188. | 17 | 138.61 | 124.46 | 196.46 |
  189. | 13 | 180.31 |  74.18 |  10.95 |
  190. | 25 | 183.63 |  12.17 |  72.96 |
  191. | 21 | 187.08 |  79.77 |  18.59 |
  192. | 20 | 194.23 |  22.11 |  90.88 |
  193. |  7 | 194.69 |  66.30 | 119.42 |
  194. |  8 | 197.20 |  44.74 | 195.10 |
  195. +----+--------+--------+--------+
  196. 27 ROWS IN SET (0.000 sec)
  197.  
  198. MariaDB [cont]> SELECT * FROM triangles WHERE side_1+side_2>side_3 OR side_1+side_3>side_2 OR side_3+side_2>side_1;
  199. +----+--------+--------+--------+
  200. | id | Side_1 | Side_2 | Side_3 |
  201. +----+--------+--------+--------+
  202. |  1 |  10.00 |  20.00 |  30.00 |
  203. |  2 |  20.00 |  10.00 |  20.00 |
  204. |  3 |  20.00 |  20.00 |  20.00 |
  205. |  4 |  30.00 |  50.00 |  40.00 |
  206. |  5 |  74.61 | 145.59 | 112.14 |
  207. |  6 | 125.86 | 175.53 | 108.06 |
  208. |  7 | 194.69 |  66.30 | 119.42 |
  209. |  8 | 197.20 |  44.74 | 195.10 |
  210. |  9 |  67.29 | 123.15 |  21.88 |
  211. | 10 | 111.93 | 102.01 | 164.27 |
  212. | 11 | 123.30 | 113.72 | 188.70 |
  213. | 12 |  19.33 |  93.56 |  17.80 |
  214. | 13 | 180.31 |  74.18 |  10.95 |
  215. | 14 |  13.22 |  23.24 |  66.54 |
  216. | 15 |  62.00 | 100.37 | 114.85 |
  217. | 16 |  72.13 | 197.12 | 186.19 |
  218. | 17 | 138.61 | 124.46 | 196.46 |
  219. | 18 |  25.92 | 103.25 |  46.48 |
  220. | 19 | 103.63 | 177.71 | 185.67 |
  221. | 20 | 194.23 |  22.11 |  90.88 |
  222. | 21 | 187.08 |  79.77 |  18.59 |
  223. | 22 |  34.67 | 107.54 |  41.72 |
  224. | 23 |  66.97 | 199.68 |  23.52 |
  225. | 24 |  81.53 | 136.12 |  44.00 |
  226. | 25 | 183.63 |  12.17 |  72.96 |
  227. | 26 | 127.29 |  25.55 | 117.89 |
  228. | 27 | 120.79 |  49.30 |  65.12 |
  229. +----+--------+--------+--------+
  230. 27 ROWS IN SET (0.006 sec)
  231.  
  232. MariaDB [cont]> SELECT * FROM triangles WHERE side_1+side_2>side_3;
  233. +----+--------+--------+--------+
  234. | id | Side_1 | Side_2 | Side_3 |
  235. +----+--------+--------+--------+
  236. |  2 |  20.00 |  10.00 |  20.00 |
  237. |  3 |  20.00 |  20.00 |  20.00 |
  238. |  4 |  30.00 |  50.00 |  40.00 |
  239. |  5 |  74.61 | 145.59 | 112.14 |
  240. |  6 | 125.86 | 175.53 | 108.06 |
  241. |  7 | 194.69 |  66.30 | 119.42 |
  242. |  8 | 197.20 |  44.74 | 195.10 |
  243. |  9 |  67.29 | 123.15 |  21.88 |
  244. | 10 | 111.93 | 102.01 | 164.27 |
  245. | 11 | 123.30 | 113.72 | 188.70 |
  246. | 12 |  19.33 |  93.56 |  17.80 |
  247. | 13 | 180.31 |  74.18 |  10.95 |
  248. | 15 |  62.00 | 100.37 | 114.85 |
  249. | 16 |  72.13 | 197.12 | 186.19 |
  250. | 17 | 138.61 | 124.46 | 196.46 |
  251. | 18 |  25.92 | 103.25 |  46.48 |
  252. | 19 | 103.63 | 177.71 | 185.67 |
  253. | 20 | 194.23 |  22.11 |  90.88 |
  254. | 21 | 187.08 |  79.77 |  18.59 |
  255. | 22 |  34.67 | 107.54 |  41.72 |
  256. | 23 |  66.97 | 199.68 |  23.52 |
  257. | 24 |  81.53 | 136.12 |  44.00 |
  258. | 25 | 183.63 |  12.17 |  72.96 |
  259. | 26 | 127.29 |  25.55 | 117.89 |
  260. | 27 | 120.79 |  49.30 |  65.12 |
  261. +----+--------+--------+--------+
  262. 25 ROWS IN SET (0.000 sec)
  263.  
  264. MariaDB [cont]> SELECT id,(side_1+side_2+side_3)AS 'perimeter' FROM triangles WHERE side_1+side_2>side_3;
  265. +----+-----------+
  266. | id | perimeter |
  267. +----+-----------+
  268. |  2 |     50.00 |
  269. |  3 |     60.00 |
  270. |  4 |    120.00 |
  271. |  5 |    332.34 |
  272. |  6 |    409.45 |
  273. |  7 |    380.41 |
  274. |  8 |    437.04 |
  275. |  9 |    212.32 |
  276. | 10 |    378.21 |
  277. | 11 |    425.72 |
  278. | 12 |    130.69 |
  279. | 13 |    265.44 |
  280. | 15 |    277.22 |
  281. | 16 |    455.44 |
  282. | 17 |    459.53 |
  283. | 18 |    175.65 |
  284. | 19 |    467.01 |
  285. | 20 |    307.22 |
  286. | 21 |    285.44 |
  287. | 22 |    183.93 |
  288. | 23 |    290.17 |
  289. | 24 |    261.65 |
  290. | 25 |    268.76 |
  291. | 26 |    270.73 |
  292. | 27 |    235.21 |
  293. +----+-----------+
  294. 25 ROWS IN SET (0.000 sec)
  295.  
  296. MariaDB [cont]> SELECT id,(round(SQRT(((side_1+side_2+side_3)/2)*(((side_1+side_2+side_3)/2)-side_1)*(((side_1+side_2+side_3)/2)-side_2)*(((side_1+side_2+side_3)/2)-side_3)),2))AS 'Area' FROM triangles WHERE side_1+side_2>side_3 ORDER BY round(SQRT(((side_1+side_2+side_3)/2)*(((side_1+side_2+side_3)/2)-side_1)*(((side_1+side_2+side_3)/2)-side_2)*(((side_1+side_2+side_3)/2)-side_3)),2) ASC;
  297. +----+---------+
  298. | id | Area    |
  299. +----+---------+
  300. | 27 |    NULL |
  301. | 12 |    NULL |
  302. | 18 |    NULL |
  303. | 20 |    NULL |
  304. |  9 |    NULL |
  305. | 21 |    NULL |
  306. |  7 |    NULL |
  307. | 22 |    NULL |
  308. | 23 |    NULL |
  309. | 24 |    NULL |
  310. | 25 |    NULL |
  311. | 13 |    NULL |
  312. |  2 |   96.82 |
  313. |  3 |  173.21 |
  314. |  4 |  600.00 |
  315. | 26 | 1448.32 |
  316. | 15 | 3106.15 |
  317. |  5 | 4113.10 |
  318. |  8 | 4354.44 |
  319. | 10 | 5618.48 |
  320. | 16 | 6710.16 |
  321. |  6 | 6750.20 |
  322. | 11 | 6757.36 |
  323. | 17 | 8570.60 |
  324. | 19 | 8996.66 |
  325. +----+---------+
  326. 25 ROWS IN SET (0.006 sec)
  327.  
  328. MariaDB [cont]> SELECT * FROM triangle WHERE side_1+side_2>side_3 AND side_1+side_3>side2 AND side_2+side_3>side_1;
  329. ERROR 1146 (42S02): TABLE 'cont.triangle' doesn't exist
  330. MariaDB [cont]> select * from triangles where side_1+side_2>side_3 and side_1+side_3>side2 and side_2+side_3>side_1;
  331. ERROR 1054 (42S22): Unknown column 'side2' in 'WHERE clause'
  332. MariaDB [cont]> select * from triangles where side_1+side_2>side_3 and side_1+side_3>side_2 and side_2+side_3>side_1;
  333. +----+--------+--------+--------+
  334. | id | Side_1 | Side_2 | Side_3 |
  335. +----+--------+--------+--------+
  336. |  2 |  20.00 |  10.00 |  20.00 |
  337. |  3 |  20.00 |  20.00 |  20.00 |
  338. |  4 |  30.00 |  50.00 |  40.00 |
  339. |  5 |  74.61 | 145.59 | 112.14 |
  340. |  6 | 125.86 | 175.53 | 108.06 |
  341. |  8 | 197.20 |  44.74 | 195.10 |
  342. | 10 | 111.93 | 102.01 | 164.27 |
  343. | 11 | 123.30 | 113.72 | 188.70 |
  344. | 15 |  62.00 | 100.37 | 114.85 |
  345. | 16 |  72.13 | 197.12 | 186.19 |
  346. | 17 | 138.61 | 124.46 | 196.46 |
  347. | 19 | 103.63 | 177.71 | 185.67 |
  348. | 26 | 127.29 |  25.55 | 117.89 |
  349. +----+--------+--------+--------+
  350. 13 rows in set (0.000 sec)
  351.  
  352. MariaDB [cont]>

Raw Paste


Login or Register to edit or fork this paste. It's free.