为了爬虫的需要,稍微预习一下mysql;
选择当前的数据库后,查看数据库信息用:
USE;
删除:DROP DATABASE spiders
#删除name为spiders的的数据库
选择:SELECT *FROM users
mysql> USE spiders;
Database changed
mysql> DESC users;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| Id | int(11) | NO | PRI | NULL | auto_increment |
| email | varchar(255) | YES | | | |
| password | varchar(255) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
3 rows in set (0.04 sec) mysql> SELECT * FROM users
-> ;
+----+----------------------+-------------+
| Id | email | password |
+----+----------------------+-------------+
| 1 | webmaster@python.org | very-secret |
| 2 | webmaster@python.org | very-secret |
| 3 | webmaster@python.org | very-secret |
| 4 | webmaster@python.org | very-secret |
| 5 | webmaster@python.org | very-secret |
| 6 | webmaster@python.org | very-secret |
| 7 | webmaster@python.org | very-secret |
+----+----------------------+-------------+
7 rows in set (0.00 sec)
cha查看数据库中的表:SHOW TABLES
mysql> SHOW TABLES;
+-------------------+
| Tables_in_spiders |
+-------------------+
| kandong |
| stu |
| users |
+-------------------+
3 rows in set (0.00 sec)
mysql> ALTER TABLE kandong ADD sha INT(10);
Query OK, 0 rows affected (0.27 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> DESC kandong;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| id | varchar(255) | NO | PRI | NULL | |
| name | varchar(255) | NO | | NULL | |
| age | int(11) | NO | | NULL | |
| sha | int(10) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
4 rows in set (0.03 sec)