View MySQL database and table structure
MySQL download and installation, see blog for details:
https://blog.csdn.net/weixin_43184774/article/details/106020174
https://blog.csdn.net/weixin_43184774/article/details/82818787
1. View the existing database
(1) After the MySQL database management system environment is installed and the login is successful, directly execute: show databases; to view the existing databases
show databases;
(2) Execute the following commands to create a teststudent database
//create database statement syntax format, which will be introduced in detail in the following chapters, so I won’t elaborate on it here.
create database teststudent;
Then execute the following command again, and you will find that there is a newly created teststudent database in the database
show databases;
2. Specify and use the database
Syntax format:
use 数据库名称;
3. View the currently used database
select database();
4. View the tables in the current database
show tables;
Because the current teststudent database is newly created, and no data table has been inserted into this database, after executing the show tables; command, the result found is Empty (empty)
5. View tables in other databases
Syntax format:
show tables from 数据库名称;
For example: View the data table in the sys database
show tables from sys;
6. View the data table structure
Syntax format:
desc 表名;
For example: if there is a student table of students locally, check the structure of the students data table
desc students;
7. View the creation statement in the data table
Syntax format:
show create table 表名;
For example: view the creation statement of the local students data table
show create table students;