This article is a record and explanation of some basic operations on the database by MySql
table of Contents
1. Check the version number-MySQL>select version();
- -SELECT is a standard SQL statement for querying data from the database;
- VERSION() is a MySQL function that returns the version information of the MySQL database.
- You need to enter a semicolon (;) after each command to be executed.
- After the input is complete, press the Enter key, the execution result is as follows:
You can also " query " in the visualization tool Navicat
2. View the database-mysql>show databases;
- Use the show databases command to view the database, all databases will be displayed
Note: MySQL server has created six databases by default after installation: information_schema,
mysql, performance_ schema, sakila, sys, and worId
.
3. Select the current database-use database name;
- Use the USE command to switch the database used by the SQL statement. The syntax is as follows:
USE 数据库名;
- E.g:
mysql>use mysql;
After the USE statement is executed, other SQL statements are executed by default on the specified database.
4. View all tables under the current database-show tables;
Display table information in the database
5. View the table structure-desc table name;
- View the specific table structure, its grammatical structure is as follows:
describe tablename;
- Example:
mysql>describe user;
displays the column information of the user table in the MySQL database
6. View storage engines-show engines;
- Storage engine : some rules for database storage, management and query operations
- Use the MySQL command "show engines;" to view
the storage engines supported by the MySQL service instance . - Several common storage engines:
- innoDB storage engine
- Default storage engine
- Support foreign keys
- Support affairs
- MYISAM
- Support full-text search
- Does not support foreign keys
- MEMERY
- Memory engine to create tables in memory
- Fast access