Common commands of MySQL database

Tip: This is the simplest MySQL database operation command


Preface

MySQL is the most popular relational database management system. MySQL is one of the best RDBMS (Relational Database Management System) application software in terms of WEB applications.


Tip: The following are the most basic commands

1. What is a database?

Database is a warehouse that organizes, stores and manages data according to data structure.
Each database has one or more different APIs for creating, accessing, managing, searching and copying the saved data.
We can also store data in files, but the speed of reading and writing data in files is relatively slow.
Therefore, now we use relational database management systems (RDBMS) to store and manage large amounts of data. The so-called relational database is a database built on the basis of a relational model, which uses mathematical concepts and methods such as set algebra to process data in the database.

Second, use steps

1. After installing the database, enter the database through the dos command

code show as below:

mysql -u(你的用户名) -p(你的密码)
//示例格式
mysql -uroot -proot
//这样写的话会让密码被别人所看见,不安全
mysql -uroot -p
Enter password: ********
//这样的话会比较安全一点

2. The basic operation of the database

code show as below:
Be sure to add a semicolon to indicate the end of the operation

    //1.查看当前所有的数据库
    show databases;
    //2.打开指定的类库
    use 库名;
    //3.查看当前库的所有表
    show tables;
    //4.查看其它库的所有表
    show tables from 库名;
    //5.创建表
    create table 表名(
    	列名 列类型,
    	列名 列类型,
    	...
    );
    //6.查看表结构
    desc 表名;
    //7.查看服务器的版本
    	//方式一:登录到mysql服务端
    	select version();
    	//方式二:没有登录到mysql服务端
    	mysql --version
    	//或者
    	mysql --V

Be sure to remember the semicolon (;) to indicate the end of the operation
Be sure to remember the semicolon (;) to indicate the end of the operation
Tell the important thing three times


3.SQL grammar specification

code show as below:

	1.不区分大小写,但是建议关键字大写,表名/列名小写
	//规范写法
	SELECT
	-> *
	-> FORM
	-> stuinfo
	//建议把每部分的数据都进行换行处理
	2.每条命令最好用分号结尾
	3.每条命令根据需要,可以进行缩进 或换行
	4.数据库注释
		单行注释: #注释文字
				 -- 注释文字(必须加空格)
		多行注释: /* 多行注释 */
		

to sum up

This is the knowledge of some basic databases. You don't need to pay much attention to the subsequent use of Navicat graphical interface, but as a basic knowledge, you still need to know more about it, okay!!!

Guess you like

Origin blog.csdn.net/xiaole060901/article/details/108214671