3. 创建数据库
3.1 显示当前数据库中所有数据库
mysql> show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| h3c_reporting |
| logistics_management |
| mysql |
| numberone-master |
| performance_schema |
| recruit |
| repairs |
| sakila |
| scenic |
| smbms |
| studentsystem |
| sys |
| tb_demo |
| world |
| xks |
+----------------------+
3.2 切换数据库
mysql> use bj2402;
Database changed
3.3 查看当前数据库中所有表
mysql> show tables;
Empty set (0.00 sec)
3.4 创建数据库同时指定字符编码
mysql> create database bj2402 character set utf8;
Query OK, 1 row affected (0.00 sec)
4. 表的创建与删除
4.1 创建表
mysql> create table student(sid int primary key auto_increment,
-> sname varchar(20),
-> sex char(2),
-> age int,
-> addr varchar(20));
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+------------------+
| Tables_in_bj2402 |
+------------------+
| student |
+------------------+
1 row in set (0.00 sec)
4.2 删除表
mysql> drop table student;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
Empty set (0.00 sec)