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