desc和show
desc只能查看表结构
查看zx1表结构
desc zx1;
mysql> desc zx1
-> ;
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| zx_name | char(1) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
show可以用来查看创建语句和查看数据库和表
查看zx1表创建语句
show create table zx1;
mysql> show create table zx1;
+-------+--------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------+
| zx1 | CREATE TABLE `zx1` (
`zx_name` char(1) DEFAULT NULL,
`age` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------------------------------------+
查看创建库的语句
show create database db1;
mysql> show create database db1;
+----------+--------------------------------------------------------------+
| Database | Create Database |
+----------+--------------------------------------------------------------+
| db1 | CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+--------------------------------------------------------------+
查看数据库
show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| db2 |
| db3 |
| db4 |
| fdg |
| mysql |
| performance_schema |
| test |
+--------------------+
查看数据表
show tables;
mysql> show tables;
+---------------+
| Tables_in_db1 |
+---------------+
| zx1 |
+---------------+