mysql 数据库的创建及使用

95 篇文章 0 订阅
56 篇文章 0 订阅

1 创建并选择数据库

如果系统管理员在设定我们权限时创建了我们的数据库,那么我们可以直接使用数据库。否则我们需要自己进行创建:

mysql> CREATE DATABASE menagerie;

在Unix系统下,数据库名字是区分大小写的(不同于SQL关键字),所以我们要使用上面创建的数据库时,需要指定为menagerie。This is also true for table names. (Under Windows, this restriction does not apply, although you must refer to databases and tables using the same lettercase throughout a given query. However, for a variety of reasons, the recommended best practice is always to use the same lettercase that was used when the database was created.)

注意:

If you get an error such as ERROR 1044 (42000): Access denied for user ‘micah’@‘localhost’ to database ‘menagerie’ when attempting to create a database, this means that your user account does not have the necessary privileges to do so. Discuss this with the administrator or see Section 6.2, “Access Control and Account Management”.

待补充:

https://dev.mysql.com/doc/refman/8.0/en/creating-database.html

创建一个数据库后我们并没有选择这个数据库,我们必须手动指定这个数据库。为了使得menagerie为当前数据库,我们需要使用如下语句:

mysql> USE menagerie
Database changed

待补充:

https://dev.mysql.com/doc/refman/8.0/en/creating-database.html

2 创建数据库的表

创建了数据库后,此时数据库为空,利用如下语句可以进行观察:

mysql> SHOW TABLES;
Empty set (0.00 sec)

接下来我们需要决定我们的数据库的结构:即我们需要哪些表,这些表中都有哪些列。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值