Mysql如何创建数据库

49次阅读
没有评论

共计 3675 个字符,预计需要花费 10 分钟才能阅读完成。

丸趣 TV 小编给大家分享一下 Mysql 如何创建数据库,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

4.1 create and drop database

C:\Users\admin mysql -h localhost -u root -pmysql

mysql: [Warning] Using a password on the
command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.14 MySQL Community
Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its
affiliates. All rights reserved.

Oracle is a registered trademark of Oracle
Corporation and/or its

affiliates. Other names may be trademarks
of their respective

owners.

Type help; or \h for help. Type \c to
clear the current input statement.

mysql
show databases;

+——————–+

| Database  |

+——————–+

| information_schema |

| mysql  |

| performance_schema |

| sys  |

| test  |

+——————–+

5 rows in set (0.00 sec)

mysql
create database example;  #create
database

Query OK, 1 row affected (0.04 sec)

mysql
show databases; 
#显示 databases

+——————–+

| Database  |

+——————–+

| information_schema |

| example  |

| mysql  |

| performance_schema |

| sys  |

| test  |

+——————–+

6 rows in set (0.00 sec)

mysql drop database example;  #drop database;

Query OK, 0 rows affected (0.04 sec)

mysql show databases;

+——————–+

| Database  |

+——————–+

| information_schema |

| mysql  |

| performance_schema |

| sys   |

| test  |

+——————–+

5 rows in set (0.00 sec)

mysql create database mysql;

ERROR 1007 (HY000): Can t create database
mysql database exists

mysql create database mydata;

Query OK, 1 row affected (0.01 sec)

4.2
存储引擎

mysql
show engines \G

*************************** 1. row
***************************

  Engine: InnoDB

  Support:
DEFAULT

  Comment: Supports transactions, row-level locking, and foreign keys

Transactions: YES

  XA: YES

  Savepoints: YES

*************************** 2. row
***************************

  Engine: MRG_MYISAM

  Support: YES

  Comment: Collection of identical MyISAM tables

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 3. row ***************************

  Engine: MEMORY

  Support: YES

  Comment: Hash based, stored in memory, useful for temporary tables

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 4. row
***************************

   Engine: BLACKHOLE

  Support: YES

  Comment: /dev/null storage engine (anything you write to it disappears)

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 5. row
***************************

  Engine: MyISAM

  Support:
YES

  Comment: MyISAM storage engine

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 6. row
***************************

  Engine: CSV

  Support: YES

  Comment: CSV storage engine

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 7. row
***************************

  Engine: ARCHIVE

  Support: YES

  Comment: Archive storage engine

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 8. row
***************************

  Engine: PERFORMANCE_SCHEMA

  Support: YES

  Comment: Performance Schema

Transactions: NO

  XA: NO

  Savepoints: NO

*************************** 9. row
***************************

  Engine: FEDERATED

   Support: NO

  Comment: Federated MySQL storage engine

Transactions: NULL

  XA: NULL

  Savepoints: NULL

9 rows in set (0.00 sec)

mysql

4.2.1 InnoDB engine

InnoDB 是 mysql 数据库中的存储引擎,innodb 给 mysql 的表提供了事务,回滚,崩溃修复能力,多版本并发控制的事务安全

(1)  Innodb 那个。存储引擎支持自动增长列 auto_increment.

(2)  Innodb 存储引擎支持外键 (foreign
key)

(3)  Innodb 存储引擎,创建的表的表结构在.frm 文件中,数据和索引存储在 innodb_data_home_dir 和 innodb_data_file_path 定义的表空间

(4)  Innodb 存储引擎的缺点是读写效率稍差,占用的数据空间相对较大。

4.2.2 MyISAM engine

MyISAM 是 mysql 中常见的存储引擎

MyISAM 存储引擎的表存储成三个文件。文件的名字与表名相同,扩展名包括 frm,MYD,MYI,

. 其中 frm 为扩展名的文件存储表的结构;MYD(MYData) 为扩展名的文件存储数据,MYI(MYindex) 为扩展名的文件存储引擎

MyISAM 存储引擎的优势在于占用空间小,处理速度快。缺点是不支持事务的完整性和并发性。

 

4.2.3 MEMORY

特殊存储引擎, 表结构在 disk 上,数据在内存中。

Memory 表的大小受到显示,表的大小取决于两个参数 max_rows 和 max_heap_table_size

4.2.4 engines 的选择.

特性

InnoDB

MyISAM

MEMORY

事务安全

支持

存储限制

64TB

空间使用

内存使用

插入数据的速度

对外键的迟滞

支持

以上是“Mysql 如何创建数据库”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-26发表,共计3675字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)