View MySQL database tables
Enter the MySQL Command line client
To view the database currently in use:
Mysql>select database ();
mysql>status;
Mysql>show tables;
Mysql>show databases;//can see which databases are available, return the database name (databaseName)
mysql>use databaseName;//Replace the currently used database
MySQL >show tables; Returns the names of all tables under the current database
Or you can use the following command directly
Mysql>show tables from Databasename;//databasename can be obtained from the show databases
MySQL view table structure commands, as follows:
DESC table name;
Show columns from table name;
Describe table name;
Show create table name;
Use Information_schema
select * from columns where table_name= ' table name ';
Rows matched:1 changed:0 warnings:1
mysql> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column ' name ' at row 3 |
+---------+------+-------------------------------------------+
1 row in Set
The above is to view the MySQL database table command Introduction.
MySQL Empty table
MySQL Clean table is a very important operation, but also one of the most common operations, the following is a detailed description of the MySQL clean up the implementation of the table, I hope to help you.
Method 1: Rebuilding libraries and tables
Use mysqldump--no-data to export the table SQL, then drop database create DATABASE, execute the exported SQL file, the table built;
Method 2: Generate SQL for emptying all tables
Mysql-n-S Information_schema-e "select CONCAT (' TRUNCATE TABLE ', table_name, '; ') From TABLES WHERE table_schema= ' eab12 '
The output results are as follows:
TRUNCATE TABLE authgroupbindings;
TRUNCATE TABLE authgroups;
TRUNCATE TABLE authusers;
TRUNCATE TABLE Corpbadcustominfo;
TRUNCATE TABLE Corpsmsblacklisyinfo;
TRUNCATE TABLE Corpsmsfilterinfo;
TRUNCATE TABLE Corpsmsinfo;
TRUNCATE TABLE Eabasereginfos;
TRUNCATE TABLE Eacorpblob;
TRUNCATE TABLE Eacorpinfo;
....
....
This is more perfect:
Copy Code code as follows:
Mysql-n-S Information_schema-e "select CONCAT (' TRUNCATE TABLE ', table_name, '; ') From TABLES WHERE table_schema= ' eab12 ' | MySQL EAB12
That is, empty all the tables in the EAB12.
But if there is a foreign key, it is likely to be an error. So we need to add a-f
Copy Code code as follows:
Mysql-n-S Information_schema-e "select CONCAT (' TRUNCATE TABLE ', table_name, '; ') From TABLES WHERE table_schema= ' eab12 ' | Mysql-f EAB12
Perform several more times until no error is made.
The above is the MySQL empty table implementation method.