Mysql returns all table names of a database, column name data type notes _mysql

Source: Internet
Author: User
DESC table name;
Show columns from table name;
describe table name;
Show create table name;

Use Information_schema
SELECT * from columns where table_name= ' table name ';


By the way, note:
show databases;
I can do that.

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) is in table Tb_webparamcounter,
Execute the following SQL modification index
ALTER TABLE Tb_webparamcounter DROP INDEX ak_pas_name;
ALTER TABLE Tb_webparamcounter add UNIQUE ak_pas_name (pc_id,pac_name);


If you find that the logic of the index is incorrect, you need to add another field to go in 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: At this time the Pc_id,pac_name,pac_value three fields are not foreign KEY
Otherwise, you must drop FOREIGN KEY first, and then redo the previous step.


Get Column name data type note
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.