• 技术文章 >数据库 >MySQL

    mysql怎么查看表及表结构

    yangyang2020-04-29 15:47:48原创3460

    查看数据库中的表

    1

    show tables

    示例:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    mysql> SHOW TABLES;

    +---------------------------+

    | Tables_in_mysql           |

    +---------------------------+

    | columns_priv              |

    | db                        |

    | engine_cost               |

    | event                     |

    | func                      |

    | general_log               |

    | gtid_executed             |

    | help_category             |

    | help_keyword              |

    | help_relation             |

    | help_topic                |

    | innodb_index_stats        |

    | innodb_table_stats        |

    | ndb_binlog_index          |

    | plugin                    |

    | proc                      |

    | procs_priv                |

    | proxies_priv              |

    | server_cost               |

    | servers                   |

    | slave_master_info         |

    | slave_relay_log_info      |

    | slave_worker_info         |

    | slow_log                  |

    | tables_priv               |

    | time_zone                 |

    | time_zone_leap_second     |

    | time_zone_name            |

    | time_zone_transition      |

    | time_zone_transition_type |

    | user                      |

    +---------------------------+

    31 rows in set (0.00 sec)

    查看表结构

    1

    desc  table_name;

    示例:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    create table person(

        id int not null auto_increment primary key,

        name varchar(8),

        index ix__person__name (name));

     

    desc person;

    +-------+------------+------+-----+---------+----------------+

    | Field | Type       | Null | Key | Default | Extra          |

    +-------+------------+------+-----+---------+----------------+

    | id    | int(11)    | NO   | PRI | NULL    | auto_increment |

    | name  | varchar(8) | YES  | MUL | NULL    |                |

    +-------+------------+------+-----+---------+----------------+

    推荐:MySQL教程

    专题推荐:mysql
    上一篇:mysql创建的数据库存在哪里 下一篇:mysql怎么查看数据

    相关文章推荐

    • mysql如何判断记录是否存在• mysql创建的数据库存在哪里

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网