Advertisement
Guest User

Untitled

a guest
Apr 16th, 2017
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. $ mysql -u root -p [/Users/jianghe/apacheServer]
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 3
  5. Server version: 5.7.17 Homebrew
  6.  
  7. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql> create database bbs_for_mysql_training;
  16. Query OK, 1 row affected (0.00 sec)
  17.  
  18. mysql> create database blog_for_mysql_training;
  19. Query OK, 1 row affected (0.00 sec)
  20.  
  21. mysql> selsect ();
  22. 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 'selsect ()' at line 1
  23. mysql> select database;
  24. 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 '' at line 1
  25. mysql> use bbs_for_mysql_training;
  26. Database changed
  27. mysql> select database();
  28. +------------------------+
  29. | database() |
  30. +------------------------+
  31. | bbs_for_mysql_training |
  32. +------------------------+
  33. 1 row in set (0.00 sec)
  34.  
  35. mysql> use blog_for_mysql_training;
  36. Database changed
  37. mysql> select database();
  38. +-------------------------+
  39. | database() |
  40. +-------------------------+
  41. | blog_for_mysql_training |
  42. +-------------------------+
  43. 1 row in set (0.00 sec)
  44.  
  45. mysql> drop database bbs_for_mysql_training;
  46. Query OK, 0 rows affected (0.01 sec)
  47.  
  48. mysql> create table users (
  49. -> id int not null auto_increment primary key,
  50. -> name varchar(255),
  51. -> age int,
  52. -> email varchar(255),
  53. -> password varchar(255)
  54. -> );
  55. Query OK, 0 rows affected (0.02 sec)
  56.  
  57. mysql> create table articles (
  58. -> id int not null auto_increment primary key,
  59. -> title varchar(255),
  60. -> category varchar(255),
  61. -> content varchar(255)
  62. -> );
  63. Query OK, 0 rows affected (0.01 sec)
  64.  
  65. mysql> show tables;
  66. +-----------------------------------+
  67. | Tables_in_blog_for_mysql_training |
  68. +-----------------------------------+
  69. | articles |
  70. | users |
  71. +-----------------------------------+
  72. 2 rows in set (0.00 sec)
  73.  
  74. mysql> desc users;
  75. +----------+--------------+------+-----+---------+----------------+
  76. | Field | Type | Null | Key | Default | Extra |
  77. +----------+--------------+------+-----+---------+----------------+
  78. | id | int(11) | NO | PRI | NULL | auto_increment |
  79. | name | varchar(255) | YES | | NULL | |
  80. | age | int(11) | YES | | NULL | |
  81. | email | varchar(255) | YES | | NULL | |
  82. | password | varchar(255) | YES | | NULL | |
  83. +----------+--------------+------+-----+---------+----------------+
  84. 5 rows in set (0.01 sec)
  85.  
  86. mysql> drop table articles;
  87. Query OK, 0 rows affected (0.01 sec)
  88.  
  89. mysql> insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp);
  90. '> ;
  91. '> insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp);
  92. 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 'soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 2' at line 1
  93. mysql> insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp); ; insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp');
  94. '> insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp); ; insert into users (name, age, email) values ('soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 26, 'sugamura@example.org'),('saito', 24, 'saito@example.co.jp');
  95. 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 'soya', 24, 'soya@example.net'), ('yuto', 24, 'yuto@example.com'), ('sugamura', 2' at line 1
  96. ERROR:
  97. No query specified
  98.  
  99. Query OK, 4 rows affected (0.00 sec)
  100. Records: 4 Duplicates: 0 Warnings: 0
  101.  
  102. mysql> select * from users;
  103. +----+----------+------+----------------------+----------+
  104. | id | name | age | email | password |
  105. +----+----------+------+----------------------+----------+
  106. | 1 | soya | 24 | soya@example.net | NULL |
  107. | 2 | yuto | 24 | yuto@example.com | NULL |
  108. | 3 | sugamura | 26 | sugamura@example.org | NULL |
  109. | 4 | saito | 24 | saito@example.co.jp | NULL |
  110. +----+----------+------+----------------------+----------+
  111. 4 rows in set (0.00 sec)
  112.  
  113. mysql> select * from users where id = 2;
  114. +----+------+------+------------------+----------+
  115. | id | name | age | email | password |
  116. +----+------+------+------------------+----------+
  117. | 2 | yuto | 24 | yuto@example.com | NULL |
  118. +----+------+------+------------------+----------+
  119. 1 row in set (0.00 sec)
  120.  
  121. mysql> select * from users where age >= 20;
  122. +----+----------+------+----------------------+----------+
  123. | id | name | age | email | password |
  124. +----+----------+------+----------------------+----------+
  125. | 1 | soya | 24 | soya@example.net | NULL |
  126. | 2 | yuto | 24 | yuto@example.com | NULL |
  127. | 3 | sugamura | 26 | sugamura@example.org | NULL |
  128. | 4 | saito | 24 | saito@example.co.jp | NULL |
  129. +----+----------+------+----------------------+----------+
  130. 4 rows in set (0.01 sec)
  131.  
  132. mysql> select email from users;
  133. +----------------------+
  134. | email |
  135. +----------------------+
  136. | soya@example.net |
  137. | yuto@example.com |
  138. | sugamura@example.org |
  139. | saito@example.co.jp |
  140. +----------------------+
  141. 4 rows in set (0.00 sec)
  142.  
  143. mysql> update users set age = 30 where id = 3;
  144. Query OK, 1 row affected (0.00 sec)
  145. Rows matched: 1 Changed: 1 Warnings: 0
  146.  
  147. mysql> update users set email = 'saito@u-tokyo.ac.jp' where id = 4;
  148. Query OK, 1 row affected (0.00 sec)
  149. Rows matched: 1 Changed: 1 Warnings: 0
  150.  
  151. mysql> delete from users where id = 1;
  152. Query OK, 1 row affected (0.00 sec)
  153.  
  154. mysql> delete from users where email like '%example%';
  155. Query OK, 2 rows affected (0.00 sec)
  156.  
  157. mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement