Advertisement
NellyIvanova29

MySQL вмъкване-обновяване-изтриване.

Oct 28th, 2021
1,239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 5.36 KB | None | 0 0
  1.  
  2. Setting environment for using XAMPP for Windows.
  3. nelly@NELLYIVANOVA c:\xampp
  4. # mysql -uroot;
  5. ERROR 1045 (28000): Access denied for user 'root;'@'localhost' (using password: NO)
  6.  
  7. nelly@NELLYIVANOVA c:\xampp
  8. # mysql -uroot
  9. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  10. Your MariaDB connection id is 18
  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)]> show databases;
  18. +--------------------+
  19. | Database           |
  20. +--------------------+
  21. | clients2610        |
  22. | information_schema |
  23. | mysql              |
  24. | performance_schema |
  25. | phpmyadmin         |
  26. | reservations       |
  27. | shoot              |
  28. | test               |
  29. | uni                |
  30. +--------------------+
  31. 9 rows in set (0.017 sec)
  32.  
  33. MariaDB [(none)]> use reservations;
  34. Database changed
  35. MariaDB [reservations]> show tables
  36.     -> ;
  37. +------------------------+
  38. | Tables_in_reservations |
  39. +------------------------+
  40. | agency                 |
  41. | clients                |
  42. | res                    |
  43. +------------------------+
  44. 3 rows in set (0.008 sec)
  45.  
  46. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES(ivan geshev, Sofia, Bulgaria, 0888888888);
  47. 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 'geshev, Sofia, Bulgaria, 0888888888)' at line 1
  48. MariaDB [reservations]>
  49. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("ivan geshev", "Sofia", "Bulgaria", "0888888888");
  50. Query OK, 1 row affected (0.025 sec)
  51.  
  52. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("boiko borisov", "Sofia", "Bulgaria", "0888888889");
  53. Query OK, 1 row affected (0.007 sec)
  54.  
  55. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("toma bikov", "Sofia", "Bulgaria", "0888888899");
  56. Query OK, 1 row affected (0.007 sec)
  57.  
  58. MariaDB [reservations]> desc agency
  59.     -> ;
  60. +---------+--------------+------+-----+---------+-------+
  61. | Field   | Type         | Null | Key | Default | Extra |
  62. +---------+--------------+------+-----+---------+-------+
  63. | name    | varchar(100) | NO   |     | NULL    |       |
  64. | city    | varchar(100) | NO   |     | NULL    |       |
  65. | country | varchar(100) | NO   |     | NULL    |       |
  66. | telnum  | varchar(10)  | NO   |     | NULL    |       |
  67. +---------+--------------+------+-----+---------+-------+
  68. 4 rows in set (0.014 sec)
  69.  
  70. MariaDB [reservations]> select * from agency;
  71. +---------------+--------------+----------+------------+
  72. | name          | city         | country  | telnum     |
  73. +---------------+--------------+----------+------------+
  74. | Nelly         | Radnevo      | Bulgaria | 0894080007 |
  75. | Gaby          | Stara Zagora | Bulgaria | 0888693322 |
  76. | ivan geshev   | Sofia        | Bulgaria | 0888888888 |
  77. | boiko borisov | Sofia        | Bulgaria | 0888888889 |
  78. | toma bikov    | Sofia        | Bulgaria | 0888888899 |
  79. +---------------+--------------+----------+------------+
  80. 5 rows in set (0.006 sec)
  81.  
  82. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("NewAgency", "Sofia", "Bulgaria", "0281931221");
  83. Query OK, 1 row affected (0.003 sec)
  84.  
  85. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("AgencyNew", "Sofia", "Bulgaria", "0281931222");
  86. Query OK, 1 row affected (0.008 sec)
  87.  
  88. MariaDB [reservations]> INSERT INTO Agency(name, city, country, telnum) VALUES("AgencyNovel", "Paris", "NULL", "0281931222");
  89. Query OK, 1 row affected (0.008 sec)
  90.  
  91. MariaDB [reservations]>
  92. MariaDB [reservations]> INSERT INTO Client(egn, name, telnum, email)) VALUES("7702031111", "Ivan Ivanov", "022121232", "ivanov@mymail.bg");
  93. 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("7702031111", "Ivan Ivanov", "022121232", "ivanov@mymail.bg")' at line 1
  94. MariaDB [reservations]> INSERT INTO Client(egn, name, telnum, email)VALUES("7702031111", "Ivan Ivanov", "022121232", "ivanov@mymail.bg");
  95. ERROR 1146 (42S02): Table 'reservations.client' doesn't exist
  96. MariaDB [reservations]> INSERT INTO Clients(egn, name, telnum, email)VALUES("7702031111", "Ivan Ivanov", "022121232", "ivanov@mymail.bg");
  97. Query OK, 1 row affected (0.011 sec)
  98.  
  99. MariaDB [reservations]> UPDATE acency
  100.    -> SET country = "France"
  101.    -> WHERE name = "AgencyNovel";
  102. ERROR 1146 (42S02): Table 'reservations.acency' doesn't exist
  103. MariaDB [reservations]> UPDATE agency
  104.     -> SET country = "France"
  105.     -> WHERE name = "AgencyNovel";
  106. Query OK, 1 row affected (0.006 sec)
  107. Rows matched: 1  Changed: 1  Warnings: 0
  108.  
  109. MariaDB [reservations]>
  110. MariaDB [reservations]> UPDATE agency
  111.     -> SET telnum = "0888112233"
  112.     -> WHERE name = "AgencyNew";
  113. Query OK, 1 row affected (0.007 sec)
  114. Rows matched: 1  Changed: 1  Warnings: 0
  115.  
  116. MariaDB [reservations]> DELETE FROM clients
  117.     -> WHERE egn = 7702031111;;
  118. Query OK, 1 row affected (0.004 sec)
  119.  
  120. ERROR: No query specified
  121.  
  122. MariaDB [reservations]> UPDATE agency
  123.     -> SET city = "Stara Zagora"
  124.     -> WHERE country = "Bulgaria";
  125. Query OK, 6 rows affected (0.008 sec)
  126. Rows matched: 7  Changed: 6  Warnings: 0
  127.  
  128. MariaDB [reservations]>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement