欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」MySQL数据库内置帮助分析(SQL语句手册)

作者 : 自学哈 本文共2380个字,预计阅读时间需要6分钟 2023-08-4 共220人阅读
也想出现在这里? 联系我们

 

MySQL数据库内置帮助分析(SQL语句手册)

MySQL数据库是关系型数据库,使用SQL语句进行数据访问,因此熟练使用SQL语句是很有必要的,那么我们如何掌握呢?其实MySQL内置的帮助已经告诉你如何使用了,一起来看看吧

 

1,登录MySQL,询问系统内置说明书

root@db02 scripts]# mysql -uroot -S /data/3306/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.36 Source distribution
Copyright (c) 2000, 2017, 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> ? contents  ##我们不知道怎么用,就问系统,你都有什么内容,下面就是它反馈给你的内容
Account Management      ##账户管理
Administration      ###管理
Compound Statements     ##复合语句
Data Definition     ##数据定义
Data Manipulation   ##数据操作
Data Types          ##数据类型
Functions       ##功能
Functions and Modifiers for Use with GROUP BY  ##与组一起使用的函数和修饰符
Geographic Features     ##地理特征
Help Metadata       ##帮助元数据
Language Structure  ##语言结构
Plugins         ##插件
Procedures      ##程序
Storage Engines     ##存储引擎
Table Maintenance       ##表维护
Transactions        ##交易
User-Defined Functions  ##用户定义的函数
Utility         ##效用

2,我们按照它给的说明书,进行下面的询问

1)例如:我们想新建1个数据库,怎么找到语法呢?

mysql> ?  Data Definition  #查看了上面的说明书,应该在数据如何定义这里面,所以?问号它;
You asked for help about help category: "Data Definition"
For more information, type 'help <item>', where <item> is one of the following
topics:
   CREATE DATABASE
   CREATE EVENT
   CREATE FUNCTION
   CREATE INDEX
   CREATE LOGFILE GROUP
   CREATE PROCEDURE
   CREATE SERVER
   CREATE TABLE
   CREATE TABLESPACE
   CREATE TRIGGER
   .....若干省略选项

2)通过上面 就找到了 CREATE DATABASE 选项,但我还是不会建立数据库啊,那继续问吧

mysql> ? CREATE DATABASE
Name: 'CREATE DATABASE'
Description:
Syntax:
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name  #这次就找到新建数据库的语法了,直接创建即可
    [create_specification] ...    ##需要注意{}大括号多选1,[]可选可忽略,其它必选
create_specification:
    [DEFAULT] CHARACTER SET [=] charset_name
  | [DEFAULT] COLLATE [=] collation_name
CREATE DATABASE creates a database with the given name. To use this
statement, you need the CREATE privilege for the database. CREATE
SCHEMA is a synonym for CREATE DATABASE.
URL: http://dev.mysql.com/doc/refman/5.6/en/create-database.html

3)下面就是根据系统提示的语法,新建一个qiuyuetao的数据库

mysql> create database qiuyuetao;
Query OK, 1 row affected (0.05 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| qiuyuetao          |
| test               |
+--------------------+
5 rows in set (0.07 sec)

3,SQL语句分为3类

1)DDL :数据定义的语言,可?Data Definition去查询

 create、alter、drop,管理基础数据:例如 库,表

2)DCL:Data control Language-数据控制语言

 grant、revoke、commit,rollback,用户授权,权限回收,数据提交回滚

3)DML:Date Manipulation Language-数据操作语言

  select、update、delete、insert,对表与记录 做操作

希望通过上面的内容,对您有所帮助,如有任何问题,可随时沟通,谢谢。

 

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」MySQL数据库内置帮助分析(SQL语句手册)
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号