标签:base desc orm prot medium select cat change user
2017-08-15 18:03:17
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| animal_protected |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set
mysql> use animal_protected;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_animal_protected |
+----------------------------+
| user_info |
+----------------------------+
1 row in set
mysql> desc user_info;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| ID | smallint(4) | NO | PRI | NULL | |
| name | char(4) | NO | | NULL | |
| kind | char(2) | NO | | NULL | |
| number | mediumint(6) | YES | | NULL | |
| address | varchar(8) | NO | | NULL | |
+---------+--------------+------+-----+---------+-------+
5 rows in set
mysql> select*from user_info;
+------+--------+------+--------+----------+
| ID | name | kind | number | address |
+------+--------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
+------+--------+------+--------+----------+
4 rows in set
mysql> select name from user_info;
+--------+
| name |
+--------+
| 美洲豹 |
| 非洲象 |
| 亚洲象 |
| 金钱豹 |
+--------+
4 rows in set
mysql> insert into user_info(ID,name,kind,number,address)values(1805,‘白熊‘,‘熊科‘,21006,‘北极
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1805‘ for key ‘PRIMARY‘
-> ;
1064 - 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 ‘Query OK, 1 row affected‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1806,‘美洲豹‘,‘猫科‘,130508,‘墨西哥
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1806‘ for key ‘PRIMARY‘
-> ;
-> ;
1064 - 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 ‘Query OK, 1 row affected
;‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1807,‘棕熊‘,‘熊科‘,90086,‘阿富汗
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1807‘ for key ‘PRIMARY‘
-> ;
1064 - 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 ‘Query OK, 1 row affected‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1808,‘华南虎‘,‘猫科‘,0,‘中国
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1808‘ for key ‘PRIMARY‘
-> ;
1064 - 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 ‘Query OK, 1 row affected‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1809,‘熊猫‘,‘熊科‘,1668,‘中国
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1809‘ for key ‘PRIMARY‘
-> ;
1064 - 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 ‘Query OK, 1 row affected‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1810,‘孟加拉虎‘,‘猫科‘,5102,‘孟加拉
‘);
Query OK, 1 row affected
1062 - Duplicate entry ‘1810‘ for key ‘PRIMARY‘
-> ;
1064 - 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 ‘Query OK, 1 row affected‘ at line 1
mysql> insert into user_info(ID,name,kind,number,address)values(1811,‘东北虎,‘猫科‘,21,‘中国
‘);
1064 - 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 ‘猫科‘,21,‘中国‘);
insert into user_info(ID,name,kind,number,address)valu‘ at line 1
mysql>
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID | name | kind | number | address |
+------+----------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1805 | 白熊 | 熊科 | 21006 | 北极 |
| 1806 | 美洲豹 | 猫科 | 130508 | 墨西哥 |
| 1807 | 棕熊 | 熊科 | 90086 | 阿富汗 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
+------+----------+------+--------+----------+
10 rows in set
mysql> insert into user_info(ID,name,kind,number,address)values(1811,‘东北虎‘,‘猫科‘,21,‘中国‘);
Query OK, 1 row affected
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID | name | kind | number | address |
+------+----------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1805 | 白熊 | 熊科 | 21006 | 北极 |
| 1806 | 美洲豹 | 猫科 | 130508 | 墨西哥 |
| 1807 | 棕熊 | 熊科 | 90086 | 阿富汗 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+----------+------+--------+----------+
11 rows in set
mysql> select *from user_info where kind="猫科";
+------+----------+------+--------+---------+
| ID | name | kind | number | address |
+------+----------+------+--------+---------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1806 | 美洲豹 | 猫科 | 130508 | 墨西哥 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+----------+------+--------+---------+
6 rows in set
mysql> select *from user_info where number<2000;
+------+--------+------+--------+---------+
| ID | name | kind | number | address |
+------+--------+------+--------+---------+
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+--------+------+--------+---------+
4 rows in set
mysql> updata user_info set address="美国" where ID=1806;
1064 - 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 ‘updata user_info set address="美国" where ID=1806‘ at line 1
mysql> select *from user_info;
+------+----------+------+--------+----------+
| ID | name | kind | number | address |
+------+----------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1805 | 白熊 | 熊科 | 21006 | 北极 |
| 1806 | 美洲豹 | 猫科 | 130508 | 墨西哥 |
| 1807 | 棕熊 | 熊科 | 90086 | 阿富汗 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+----------+------+--------+----------+
11 rows in set
mysql> update user_info set name=‘美洲狮‘ address=‘美国‘ where ID=1806;
1064 - 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 ‘address=‘美国‘ where ID=1806‘ at line 1
mysql> update user_info set name="美洲狮" where ID=1806;
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update user_info set address="美国" where ID=1806;
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select*from user_info;
+------+----------+------+--------+----------+
| ID | name | kind | number | address |
+------+----------+------+--------+----------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1802 | 非洲象 | 象科 | 357281 | 津巴布韦 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1805 | 白熊 | 熊科 | 21006 | 北极 |
| 1806 | 美洲狮 | 猫科 | 130508 | 美国 |
| 1807 | 棕熊 | 熊科 | 90086 | 阿富汗 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+----------+------+--------+----------+
11 rows in set
mysql> delect from user_info where number>100000;
1064 - 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 ‘delect from user_info where number>100000‘ at line 1
mysql> delete from user_info where number>100000;
Query OK, 2 rows affected
mysql> select*from user_info;
+------+----------+------+--------+---------+
| ID | name | kind | number | address |
+------+----------+------+--------+---------+
| 1801 | 美洲豹 | 猫科 | 16663 | 墨西哥 |
| 1803 | 亚洲象 | 象科 | 52359 | 印度 |
| 1804 | 金钱豹 | 猫科 | 78 | 孟加拉 |
| 1805 | 白熊 | 熊科 | 21006 | 北极 |
| 1807 | 棕熊 | 熊科 | 90086 | 阿富汗 |
| 1808 | 华南虎 | 猫科 | 0 | 中国 |
| 1809 | 熊猫 | 熊科 | 1668 | 中国 |
| 1810 | 孟加拉虎 | 猫科 | 5102 | 孟加拉 |
| 1811 | 东北虎 | 猫科 | 21 | 中国 |
+------+----------+------+--------+---------+
9 rows in set
mysql>
标签:base desc orm prot medium select cat change user
原文地址:http://www.cnblogs.com/lyxcode/p/7366527.html