How to return all table names and column data types of a database in MySQL

Source: Internet
Author: User
Desc table name; show columns from table name; Describe table name; show create table table name; Use information_schemaselect * from columns where table_name = 'table name'; write down: Show databases;

You can also

Use information_schema

Select table_schema, table_name from tables where table_schema = 'database name'

Use Database Name; show tables; the original unique index ak_pas_name (pac_name) in the tb_webparamcounter table, run the following SQL statement to modify the index ALTER TABLE tb_webparamcounter drop index ak_pas_name; alter table tb_webparamcounter add unique ak_pas_name (pc_id, pac_name); if the index logic is incorrect, add another field and execute alter table tb_webparamcounter drop index ak_pas_name; alter table tb_webparamcounter add unique ak_pas_name (pc_id, pac_name, pac_value); note: In this case, the pc_id, pac_name, and pac_value fields are not foreign keys. Otherwise, you must drop Foreign keys first, redo the previous step to obtain the column Name Data Type remarks.

Select column_name, data_type, column_comment from information_schema.columns where table_name =?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.