MySQL Statement Review

Source: Internet
Author: User

MySQL Statement Review show databases; // display all databases select database (); // view the current database show tables; // display the Table Name USER db_name [;] // switch database desc tb_name; /DESCRIBE city;/EXPLAIN city; // display database column information SHOW columns FROM db_name; // display database column Information select version (); // query the current database version select curdata ();/SELECT CURRENT_DATE; // query the current date (yyyy-MM-dd) select now (); // query the current time (yyyy-MM-dd HH: mm: ss) select user (); // query the current Logon account select user () \ c // cancel executing the current statement create database mydb; // create database 'mydb' (databases in Unix-like environments are case sensitive) create table tb_name (co_name co_type ...); // create a table load data local infile '/path/pet.txt' into table pet [lines terminated by '\ r \ n']; // import data from a local file into the table select year (CURDATE (); // query the select month (CURDATE () of the current YEAR ()); // query the current month select dayofmonth (CURDATE (); // query the current day select right (CURDATE (), 5); // right usage select left (CURDATE (), 7); // left usage SELECT DATE_ADD (CURDATE (), INTERVAL n MONTH); // DATE_ADD usage, where n is an integer (negative value indicates subtraction) SELECT DATE_ADD (CURDATE (), INTERVAL n YEAR); SELECT DATE_ADD (CURDATE (), INTERVAL n DAY); select mod (12, 5);/SELECT 12% 5; // return the remainder operation SELECT * FROM tb_name WHERE co_name REGEXP 'regexp '; // Regular Expression fuzzy match query (NOT regexp, RLIKE, not rlike) show index from db_name; // view the index information SOURCE filename; // run the SQL script (source D:/mysql. SQL;) ALTER TABLE tb_name AUTO_INCREMENT = n; // modify auto-increment from n SELECT CONCAT (str ...); // concatenate the string (any number) show engines; // view the database engine alter table tb_name MODIFY co_name data_type; // MODIFY the Data Type of the TABLE field analyze table tb_name; // helps optimize the index

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.