MariaDB 库的基本操作

2022-12-28 13:43:31 浏览数 (1)

> ♥ 文章声明 ♥ > 该系列文章部分文字描述,参考于以下文献,化繁为简. > 《MySQL5.7从入门到精通》 - 刘增杰

## 创建数据库

1.创建一个`lyshark`数据库. ```SQL MariaDB [(none)]> create database lyshark charset utf8; Query OK, 1 row affected (0.00 sec) ``` 2.查看创建好的数据库lyshark的定义 ```SQL MariaDB [(none)]> show create database lysharkG *************************** 1. row *************************** Database: lyshark Create Database: CREATE DATABASE `lyshark` /*!40100 DEFAULT CHARACTER SET gbk */ 1 row in set (0.00 sec) ``` ## 查询数据库

1.显示所有数据库 ```SQL MariaDB [(none)]> show databases; -------------------- | Database | -------------------- | information_schema | | lyshark | | mysql | | performance_schema | -------------------- 4 rows in set (0.00 sec) MariaDB [(none)]> ``` 2.匹配以lys开头的数据库 ```SQL MariaDB [(none)]> show databases like 'lys%'; ----------------- | Database (lys%) | ----------------- | lyshark | ----------------- 1 row in set (0.00 sec) MariaDB [(none)]> ``` ## 更新数据库

1.修改指定数据库的字符集为gbk ```SQL MariaDB [(none)]> alter database lyshark charset gbk; Query OK, 1 row affected (0.00 sec) ``` ## 删除数据库

```SQL MariaDB [(none)]> drop database lyshark; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show databases; -------------------- | Database | -------------------- | information_schema | | mysql | | performance_schema | -------------------- 3 rows in set (0.00 sec) MariaDB [(none)]> ```

0 人点赞