Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql -u root -p [/Users/jianghe/apacheServer]
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 3
- Server version: 5.7.17 Homebrew
- Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> create database bbs_for_mysql_training;
- Query OK, 1 row affected (0.00 sec)
- mysql> create database blog_for_mysql_training;
- Query OK, 1 row affected (0.00 sec)
- mysql> selsect ();
- 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
- mysql> select database;
- 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
- mysql> use bbs_for_mysql_training;
- Database changed
- mysql> select database();
- +------------------------+
- | database() |
- +------------------------+
- | bbs_for_mysql_training |
- +------------------------+
- 1 row in set (0.00 sec)
- mysql> use blog_for_mysql_training;
- Database changed
- mysql> select database();
- +-------------------------+
- | database() |
- +-------------------------+
- | blog_for_mysql_training |
- +-------------------------+
- 1 row in set (0.00 sec)
- mysql> drop database bbs_for_mysql_training;
- Query OK, 0 rows affected (0.01 sec)
- mysql> create table users (
- -> id int not null auto_increment primary key,
- -> name varchar(255),
- -> age int,
- -> email varchar(255),
- -> password varchar(255)
- -> );
- Query OK, 0 rows affected (0.02 sec)
- mysql> create table articles (
- -> id int not null auto_increment primary key,
- -> title varchar(255),
- -> category varchar(255),
- -> content varchar(255)
- -> );
- Query OK, 0 rows affected (0.01 sec)
- mysql> show tables;
- +-----------------------------------+
- | Tables_in_blog_for_mysql_training |
- +-----------------------------------+
- | articles |
- | users |
- +-----------------------------------+
- 2 rows in set (0.00 sec)
- mysql> desc users;
- +----------+--------------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +----------+--------------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | name | varchar(255) | YES | | NULL | |
- | age | int(11) | YES | | NULL | |
- | email | varchar(255) | YES | | NULL | |
- | password | varchar(255) | YES | | NULL | |
- +----------+--------------+------+-----+---------+----------------+
- 5 rows in set (0.01 sec)
- mysql> drop table articles;
- Query OK, 0 rows affected (0.01 sec)
- 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);
- 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
- 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');
- '> 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');
- 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
- ERROR:
- No query specified
- Query OK, 4 rows affected (0.00 sec)
- Records: 4 Duplicates: 0 Warnings: 0
- mysql> select * from users;
- +----+----------+------+----------------------+----------+
- | id | name | age | email | password |
- +----+----------+------+----------------------+----------+
- | 1 | soya | 24 | soya@example.net | NULL |
- | 2 | yuto | 24 | yuto@example.com | NULL |
- | 3 | sugamura | 26 | sugamura@example.org | NULL |
- | 4 | saito | 24 | saito@example.co.jp | NULL |
- +----+----------+------+----------------------+----------+
- 4 rows in set (0.00 sec)
- mysql> select * from users where id = 2;
- +----+------+------+------------------+----------+
- | id | name | age | email | password |
- +----+------+------+------------------+----------+
- | 2 | yuto | 24 | yuto@example.com | NULL |
- +----+------+------+------------------+----------+
- 1 row in set (0.00 sec)
- mysql> select * from users where age >= 20;
- +----+----------+------+----------------------+----------+
- | id | name | age | email | password |
- +----+----------+------+----------------------+----------+
- | 1 | soya | 24 | soya@example.net | NULL |
- | 2 | yuto | 24 | yuto@example.com | NULL |
- | 3 | sugamura | 26 | sugamura@example.org | NULL |
- | 4 | saito | 24 | saito@example.co.jp | NULL |
- +----+----------+------+----------------------+----------+
- 4 rows in set (0.01 sec)
- mysql> select email from users;
- +----------------------+
- | email |
- +----------------------+
- | soya@example.net |
- | yuto@example.com |
- | sugamura@example.org |
- | saito@example.co.jp |
- +----------------------+
- 4 rows in set (0.00 sec)
- mysql> update users set age = 30 where id = 3;
- Query OK, 1 row affected (0.00 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
- mysql> update users set email = 'saito@u-tokyo.ac.jp' where id = 4;
- Query OK, 1 row affected (0.00 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
- mysql> delete from users where id = 1;
- Query OK, 1 row affected (0.00 sec)
- mysql> delete from users where email like '%example%';
- Query OK, 2 rows affected (0.00 sec)
- mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement