How to get database structure in MySQL via query

前端 未结 10 1328
旧时难觅i
旧时难觅i 2020-11-27 11:37

Is it possible to somehow get structure of MySQL database, or just some table with simple query?

Or is there another way, how can I do it?

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 11:58

    Take a look at the INFORMATION_SCHEMA.TABLES table. It contains metadata about all your tables.

    Example:

    SELECT * FROM `INFORMATION_SCHEMA`.`TABLES`
    WHERE TABLE_NAME LIKE 'table1'
    

    The advantage of this over other methods is that you can easily use queries like the one above as subqueries in your other queries.

提交回复
热议问题