MySQL Common functions

Source: Internet
Author: User

 MySQL linked server mysql-h localhost-u root-p * Show databases Display database * Use dbname Select database * Show tables show datasheet *create database Database name Build library * Drop DB dbname Delete library * Delete Database dbname Delete Library * CREATE table < table name > (< Field name 1> < type 1> [,.. < Field name N> < type N&GT;]) Build table * Rename table name to new table name change table name * Update table name SET field = new value,... Where condition modify table data * Update table name set field name = New Content Change table field * Show Character set display character set * Show collation display character Set's proofreading * Character set character set name offset character Set * Set names set CharSet * character_set_ Client-side Character set * character_set_connection link Character set * character_set_results return character set * INSERT INTO Dbname.tablename Select FieldName from Dbname.tablename; Import data from other tables My additional commands: 1. Switch to the Msyqld.exe path using the CD if you want to switch to a different drive letter, such as: C: or D: or E: or f:2. Find the MySQL installation directory, such as my: D:\wamp\bin\mysql\mysql5.6.12 \ bin Switch to the Msyqld.exe path using the CD, and then enter the MySQL connection command if the command line is the native of MySQL and the default port 3306 is the direct input mysql-u root-p can empty the data table: empty a table named ABC, So write sql:truncate table abc; This empty ID will start from 1. Or: delete from ABC; Export database: Mysqldump-u user name-p database name > exported file name as I entered the command line: mysqldump-u root-P ygeshop > Ygeshop.sql (Will let you enter MySQL password after input) (if you export a single table, enter the table name after the database name) MySQL display table fields and comments and other information show DATABASES Lists the MySQL Server databases. SHOW TABLES [from db_name]//Lists database data tables. SHOW table status [from db_name]//Lists data tables and table state information. Show COLUMNS from Tbl_name [from db_name]//List table fields Show field from Tbl_name [from Db_name],describe tbl_name [Col_nam E]. Show full COLUMNS from Tbl_name [from db_name]//list fields and details show field from Tbl_name [from db_name]//List field complete properties show INDEX From Tbl_name [from db_name]//List table index. SHOW Status//Lists the DB Server status. SHOW VARIABLES//Lists the MySQL system environment variables. SHOW processlist//Lists the execution commands. SHOW GRANTS for user//List a user right
MySQL Date_format () function
MySQL Date function


Definition and usage
The Date_format () function is used to display date/time data in different formats.


Grammar
Date_format (Date,format)
The date parameter is a valid day. format Specifies the date/time in which the output is formatted.


The formats you can use are:
Format description
%a Abbreviated Week name
%b Abbreviated month name
%c month, numeric
%d Day of the month with English prefixes
%d months of the day, value (00-31)
%e Month Day, value (0-31)
%f μs
%H hours (00-23)
%h hours (01-12)
%I Hours (01-12)
%i min, numeric (00-59)
Day of the%j year (001-366)
%k hours (0-23)
%l hours (1-12)
%M Month Name
%m month, value (00-12)
%p AM or PM
%r time, 12-hour (Hh:mm:ss AM or PM)
%s seconds (00-59)
%s seconds (00-59)
%T time, 24-hour (HH:MM:SS)
%u week (00-53) Sunday is the first day of the week
%u week (00-53) Monday is the first day of the week
%V Week (01-53) Sunday is the first day of the week, with%x
%v Week (01-53) Monday is the first day of the week, with%x
%W Week Name
%w Day of the week (0= Sunday, 6 = Saturday)
%x year, of which Sunday was the first day of the week, 4-bit, with%V used
%x year, of which Monday was the first day of the week, 4-bit, with%v used
%Y year, 4 people
%y year, 2 people

  

MySQL Common functions

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.