MySQL statement notes

Source: Internet
Author: User

1. Querying all non-empty field names in a table

SELECT ' column_name ' from ' information_schema '. ' COLUMNS ' WHERE ' is_nullable ' = ' No ' and ' table_name ' = ' feed ' and ' table_ SCHEMA ' = ' prodb_mgmt '

2. View all fields of a table

< table name >

3. View the table size Http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database

SELECT     table_name as ' table ',     Round ((((Data_length + index_length)/1024/1024), 2) ' Size in MB ' from information _schema. TABLES WHERE table_schema = "$DB _name" and    table_name = "$TABLE _name";

4. Display the table's build statement http://dev.mysql.com/doc/refman/5.7/en/show-create-table.html

Mysql>ShowCreate TableServerstatusinfo \g;*************************** 1. Row***************************       Table: ServerstatusinfoCreate Table:CREATE TABLE' Serverstatusinfo ' (' Date ' date not NULL, ' server 'varchar( $) not NULL, ' Requestsactivemax 'int(Ten) unsigneddefault '0', ' Requesttimemax 'int(Ten) unsigneddefault '0', ' Requesttimemean 'float default '0', ' Requesttimestddev 'float default '0',  PRIMARY KEY(' Date ', ' server ') ENGINE=InnoDBDEFAULTCHARSET=GBK1Rowinch Set(0.00Sec

4. Delete all data in the table Delete/truncate

Delete from Tablename;delete:will the delete all rows from your table. Next insert would take next auto increment id.truncate tableName; Truncate:will also delete the rows from your table but it'll start from new row with 1.

  

MySQL statement notes

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.