Mysql- Common Command Summary

MySQL database in SQL Usage:
See all database information MySQL database connection in the project:

show databases;

Production database to see information about the current project connected:

select database();

All data tables show information about the current connection to the database:

show tables;

Find all information users of MySQL:

select distinct concatt('user:',user,'@',host,';') as query from mysql.user;

View annotation information data table and field:

SELECT t.TABLE_NAME,t.TABLE_COMMENT,c.COLUMN_NAME,c.COLUMN_COMMENT 
FROM information_schema.TABLES t,INFORMATION_SCHEMA.Columns c 
WHERE c.TABLE_NAME=t.TABLE_NAME AND t.`TABLE_SCHEMA`='website'

Explanation:

TABLE_NAME: table name, TABLE_COMMENT Table Notes 
COLUMN_NAME: column names, COLUMN_COMMENT Column Comments 
TABLE_SCHEMA: database name

View the port number for the database:

show variables like 'port';

Check the size of the database:

select concat(round(sum(data_length)/(1024*1024),2) + round(sum(index_length)/(1024*1024),2),'MB')
as 'DB Size' from tables where table_schema='website'

Check the maximum number of connections to the database:

show variables like '%max_connections%';

View Database version information:

select version() from dual;

Display the current time:

current_timestamp();

View the current user name:

SELECT USER();

See all tables in the database:

show tables in website;

  SQL transactions in:
        MySQL:
            approach there are two matters:
                1:
                    the begin open transaction
                    rollback transaction rollback
                    commit the transaction commits
                2.
                    the SET autocommit = 0 disable automatic submission
                    set autocommit = 1 enable auto-commit
encryption algorithm (MySQL built-in):

Password ( ' string ' ); 

the MD5 ( ' string ' ); 

ENCODE ( ' character string ' , ' Encryption Standard string ' ); 

The DECode ( ' character string ' , ' decryption standard string ' ); 
Note: Encryption and decryption string so that the same 

embodiment: the INSERT  the INTO Test (pword in, name, NO) values (the MD5 ( ' 123 ' ), ' the SS ' , ' 123456 ' )

Guess you like

Origin www.cnblogs.com/lixianglong/p/12195109.html