发表于: 2017-08-17 23:57:40

1 947


今天完成的事情

1. 复习上次学习内容,由于中途处理事情;

2. 又新学习在命令行和navicat上备份/恢复表以及数据库;


明天计划的事情

1. 继续复习整理前段时间所学内容;

2. 学习主要的sql语句操作并总结。


遇到的问题

1. 在MySQL上备份时mysqldump,一直不成功;百度发现mysqldump不是在mysql下,而是在D盘运行;

2.恢复备份的时候,要注明路径,否则提示错误;


收获

D:\>mysql -uroot -p
Enter password: ****

mysql> use task1;
Database changed


mysql> show cloumns;
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 'cloumns' at line 1


mysql> desc entroll1;
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| ID        | int(11)     | NO   | PRI | NULL    | auto_increment |
| target    | varchar(50) | YES  |     | NULL    |                |
| launch    | varchar(50) | YES  |     | NULL    |                |
| education | varchar(50) | YES  |     | NULL    |                |
| study_id  | varchar(50) | YES  |     | NULL    |                |
| daily_ur  | varchar(50) | YES  |     | NULL    |                |
| slogan    | varchar(50) | YES  |     | NULL    |                |
| brother   | varchar(50) | YES  |     | NULL    |                |
| channel   | varchar(50) | YES  |     | NULL    |                |
| name      | varchar(15) | YES  |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)


mysql> insert into  enteoll1 VALUES ('null','java','2017.8','peking','java-2277','http//www.baidu.com','我是好人','刘师 兄','知乎','Big杜大大');
ERROR 1146 (42S02): Table 'task1.enteoll1' doesn't exist


mysql> insert into  entroll1 VALUES ('null','java','2017.8','peking','java-2277','http//www.baidu.com','我是好人','刘师 兄','知乎','Big杜大大');
ERROR 1366 (HY000): INCORRECT INTEGER VALUE:                  'NULL'                    FOR COLUMN 'ID' AT ROW 1         

    

mysql> insert into  entroll1 VALUES (             '0'              ,'java','2017.8','peking','java-2277','http//www.baidu.com','我是好人','刘师 兄','知乎','Big杜大大');
Query OK, 1 row affected (0.42 sec)


mysql> select*from entroll1;

+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
| ID | target | launch | education | study_id  | daily_ur            | slogan       | brother    | channel | name         |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
|  1 | java   | 2017.8 | peking    | java-2277 | http//www.baidu.com | 我是好人     | 刘师 兄    | 知乎    | Big杜大大    |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
1 row in set (0.00 sec)


mysql> delete from entroll1 where ID=1;
Query OK, 1 row affected (0.22 sec)


mysql> select*from entroll1;
Empty set (0.00 sec)


mysql> insert into  entroll1 VALUES (                 '1'                            ,'java','2017.8','peking','java-2277','http//www.baidu.com','我是好人','刘师 兄','知乎','Big杜大大');
Query OK, 1 row affected (0.12 sec)


mysql> select*from entroll1;
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
| ID | target | launch | education | study_id  | daily_ur            | slogan       | brother    | channel | name         |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
|  1 | java   | 2017.8 | peking    | java-2277 | http//www.baidu.com | 我是好人     | 刘师 兄    | 知乎    | Big杜大大    |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
1 row in set (0.00 sec)


mysql> select target slogan from entroll1;
+--------+
| slogan |
+--------+
| java   |
+--------+
1 row in set (0.00 sec)


mysql> select target ,slogan from entroll1;
+--------+--------------+
| target | slogan       |
+--------+--------------+
| java   | 我是好人     |
+--------+--------------+
1 row in set (0.00 sec)


mysql> select* from entroll1 where name='Big'
    -> ;
Empty set (0.00 sec)


mysql> select* from entroll1 where name='Big杜大大'
    -> select*from entroll1 where name='Big杜大大 '
    ->
    ->
    -> ;
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 ';


mysql> select*from entroll1 where name='Big杜大大 ';
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
| ID | target | launch | education | study_id  | daily_ur            | slogan       | brother    | channel | name         |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
|  1 | java   | 2017.8 | peking    | java-2277 | http//www.baidu.com | 我是好人     | 刘师 兄    | 知乎    | Big杜大大    |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
1 row in set (0.00 sec)


mysql> update entroll1 set slogan=老大最帅 where id=1;
ERROR 1054 (42S22): Unknown column '老大最帅' in 'field list'


mysql> update entroll1 set slogan='老大最帅' where id=1;
Query OK, 1 row affected (0.38 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> select*from entroll1;
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
| ID | target | launch | education | study_id  | daily_ur            | slogan       | brother    | channel | name         |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
|  1 | java   | 2017.8 | peking    | java-2277 | http//www.baidu.com | 老大最帅     | 刘师 兄    | 知乎    | Big杜大大    |
+----+--------+--------+-----------+-----------+---------------------+--------------+------------+---------+--------------+
1 row in set (0.00 sec)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| task1              |
| task1.1            |
| tt                 |
+--------------------+
7 rows in set (0.00 sec)


mysql> drop database tt;
Query OK, 0 rows affected (0.14 sec)



mysql> mysqldump -uroot -p1234 task1 >db.sql;
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 'mysqldump -uroot -p1234 task1 >db.sql' at line 1
mysql> \q;
Bye


D:\>mysqldump -uroot -p task1 entroll1 >db.sql;
Enter password: ****
mysqldump: Couldn't find table: ";"

mysql> show tables;
ERROR 1046 (3D000): No database selected


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| task1              |
+--------------------+
5 rows in set (0.00 sec)


mysql> alter table  entroll1 rename to entroll;
Query OK, 0 rows affected (0.47 sec)


mysql> show tables;
+-----------------+
| Tables_in_task1 |
+-----------------+
| entroll         |
| entroll6        |
+-----------------+
2 rows in set (0.00 sec)


mysql> alter table entroll6 rename entroll5;
Query OK, 0 rows affected (0.20 sec)


mysql> desc enroll5;
ERROR 1146 (42S02): Table 'task1.enroll5' doesn't exist


mysql> desc entroll5;
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| ID        | bigint(11)   | NO   | PRI | NULL    | auto_increment |
| creat-at  | bigint(20)   | YES  |     | NULL    |                |
| update-at | bigint(20)   | YES  |     | NULL    |                |
| name      | varchar(20)  | YES  |     | NULL    |                |
| qq        | int(15)      | YES  |     | NULL    |                |
| target    | varchar(20)  | YES  |     | NULL    |                |
| launch    | date         | YES  |     | NULL    |                |
| education | varchar(50)  | YES  |     | NULL    |                |
| study_id  | int(15)      | YES  |     | NULL    |                |
| daily_ur  | varchar(50)  | YES  |     | NULL    |                |
| slogan    | varchar(100) | YES  |     | NULL    |                |
|  brother  | varchar(10)  | YES  |     | NULL    |                |
|  channel  | varchar(100) | YES  |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
13 rows in set (0.01 sec)

mysql> \q;

Bye

D:\>mysqldump -uroot -p task1 >da.sql
Enter password: ****

mysql> use task;
Database changed


mysql> source E:/sql/da.sql;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.53 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.03 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.17 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.03 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)


ps:师兄,我回来了,时间紧,写的仓促了。。。。




返回列表 返回列表
评论

    分享到