Home > Database > Mysql Tutorial > body text

What are the commonly used basic SQL statements in MYSQL?

醉折花枝作酒筹
Release: 2021-07-16 09:21:29
forward
2657 people have browsed it

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     --启动
Copy after login

Login to mysql

mysql -h localhost -u root -P 3306 -p
mysql -h localhost -u root -p 123456
Copy after login

Exit mysql

mysql>exit;
Copy after login

View database

mysql>SHOW DATABASES;
Copy after login

Create and delete database

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

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

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

Display the data table in the library

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

Create And delete the data table

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

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;
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!