- 查看数据库->show databases;
- 建数据库->create database 数据库名;
- 建表->use 数据库名;->create table 表名(字段);
- 查看所有表->show tables;
- 查看表信息->desc 表名;
- 删除表->drop database 数据库名;
1 mysql> show databases; 2 +--------------------+ 3 | Database | 4 +--------------------+ 5 | information_schema | 6 | mysql | 7 | test | 8 +--------------------+ 9 3 rows in set (0.02 sec)10 11 mysql> create database addr;12 Query OK, 1 row affected (0.00 sec)13 14 mysql> show databases;15 +--------------------+16 | Database |17 +--------------------+18 | information_schema |19 | addr |20 | mysql |21 | test |22 +--------------------+23 4 rows in set (0.00 sec)24 25 mysql> use addr;26 Database changed27 mysql> show tables;28 Empty set (0.02 sec)29 30 mysql> create table address(31 -> id int primary key auto_increment,32 -> name varchar(20),33 -> street varchar(20),34 -> city varchar(20),35 -> state varchar(20),36 -> zip varchar(6)37 -> );38 Query OK, 0 rows affected (0.19 sec)39 40 mysql> show tables;41 +----------------+42 | Tables_in_addr |43 +----------------+44 | address |45 +----------------+46 1 row in set (0.00 sec)47 48 mysql> desc address;49 +--------+-------------+------+-----+---------+----------------+50 | Field | Type | Null | Key | Default | Extra |51 +--------+-------------+------+-----+---------+----------------+52 | id | int(11) | NO | PRI | NULL | auto_increment |53 | name | varchar(20) | YES | | NULL | |54 | street | varchar(20) | YES | | NULL | |55 | city | varchar(20) | YES | | NULL | |56 | state | varchar(20) | YES | | NULL | |57 | zip | varchar(6) | YES | | NULL | |58 +--------+-------------+------+-----+---------+----------------+59 6 rows in set (0.02 sec)60 61 mysql> insert into address (name,street,city,state,zip) values('111','111','111'62 ,'111','111');63 Query OK, 1 row affected (0.09 sec)64 65 mysql> insert into address (name,street,city,state,zip) values('222','222','111'66 ,'111','111');67 Query OK, 1 row affected (0.05 sec)68 69 mysql> insert into address (name,street,city,state,zip) values('333','333','111'70 ,'111','111');71 Query OK, 1 row affected (0.05 sec)72 73 mysql> select * from address;74 +----+------+--------+------+-------+------+75 | id | name | street | city | state | zip |76 +----+------+--------+------+-------+------+77 | 1 | 111 | 111 | 111 | 111 | 111 |78 | 2 | 222 | 222 | 111 | 111 | 111 |79 | 3 | 333 | 333 | 111 | 111 | 111 |80 +----+------+--------+------+-------+------+81 3 rows in set (0.00 sec)82 83 mysql>