Home  >  Article  >  Database  >  What are the commonly used basic SQL statements in MYSQL?

What are the commonly used basic SQL statements in MYSQL?

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-07-16 09:21:292693browse

What are the commonly used basic SQL statements in MYSQL? I don’t know if you know it. Today I will take you to review the commonly used SQL statements. Friends in need can refer to them.

What are the commonly used basic SQL statements in MYSQL?

Starting and stopping mysql service

net stop mysql    --停止 
net start mysql     --启动

Login to mysql

mysql -h localhost -u root -P 3306 -p
mysql -h localhost -u root -p 123456

Exit mysql

mysql>exit;

View database

mysql>SHOW DATABASES;

Create and delete database

mysql>CREATE { DATABASE | SCHEMA } [ IF NOT EXISTS ] db_name [DEFAULT] CHARACTER SET [ = ] charset_name; --创建
mysql>DROP DATABASE db_name;  --删除

View the database storage engine, use the database, view the currently used database

mysql>SHOW ENGINES;  --查看存储引擎
mysql>USE db_name;     --使用数据库
mysql>SELECT DATABASE(); --查看当前使用的数据库

Display the data table in the library

mysql>USE db_name;   --使用数据库
mysql>SHOW TABLES;   --显示数据表

Create And delete the data table

mysql>CREATE  TABLE [IF NOT EXISTS] table_name(column_name column_type...) --创建
mysql>DROP TABLE table_name;    --删除

View the structure of the data table

mysql>DESC table_name;
mysql>DESCRIBE table_name;
mysql>EXPLAIN  table_name;
mysql>SHOW COLUMNS FROM  table_name;

Related recommendations: "mysql tutorial"

The above is the detailed content of What are the commonly used basic SQL statements in MYSQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete