View table structure
For a successfully created data table, you can use the SHOW COLUMNS statement or DESCRIBE statement to view the table structure of the specified data table. These two statements are introduced below.
1.SHOW COLUMNS statement
The syntax format of the SHOW COLUMNS statement is as follows:
SHOW [FULL]COLUMNS FROM data table name [FROM database name ];
or
SHOW [FULL]COLUMNS FROM data table name.database name;
2.DESCRIBE statement
The syntax format of the DESCRIBE statement is as follows:
DESCRIBE data table name;
Among them, DESCRIBE can be abbreviated as DESC. When viewing the table structure, you can also list only the information of a certain column. The syntax format is as follows:
DESC data table name column name;
Rename table
Rename the table using the RENAME TABLE statement, the syntax is as follows:
RENAME TABLE data table name 1 to data table name 2;
For example: change the admin table name to user, the format is as follows:
rename table admin to user;
This statement can rename multiple data tables at the same time. Multiple tables are separated by commas.
Delete table
The operation of deleting a data table is very simple. It is similar to the operation of deleting a database and can be achieved by using the DROP TABLE statement. The format is as follows:
DROP TABLE data table name;
For example: to delete the data table admin, the method is as follows:
drop table admin;
and delete Just like the database, once the table is deleted, all the data in the table will be cleared, and it cannot be restored without a backup.
During the deletion process, if you delete a non-existent table, an error will occur. If you add the IF EXISTS keyword to the delete statement, there will be no error. The format is as follows:
drop table if exists data table name;
The above is the detailed content of View, delete and rename data tables in MySQL (MYSQL data table operation tutorial 3). For more information, please follow other related articles on the PHP Chinese website!