Basic operation of MySql database (1)

This article is a record and explanation of some basic operations on the database by MySql

1. Check the version number-MySQL>select version();

  1. -SELECT is a standard SQL statement for querying data from the database;
  2. VERSION() is a MySQL function that returns the version information of the MySQL database.
  3. You need to enter a semicolon (;) after each command to be executed.
  4. After the input is complete, press the Enter key, the execution result is as follows:
    Insert picture description here

You can also " query " in the visualization tool Navicat
Insert picture description here

2. View the database-mysql>show databases;

  • Use the show databases command to view the database, all databases will be displayed
    Insert picture description here

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.
Insert picture description here

4. View all tables under the current database-show tables;

Display table information in the database
Insert picture description here

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
    Insert picture description here

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:
  1. innoDB storage engine
    • Default storage engine
    • Support foreign keys
    • Support affairs
  2. MYISAM
    • Support full-text search
    • Does not support foreign keys
  3. MEMERY
    • Memory engine to create tables in memory
    • Fast access

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45768060/article/details/108572493