Differences between char and varcharChar (13) is fixed in length. For example, the storage space of 'www .jb51.net' must be 12 characters long.Varchar (13) Variable Length: for example, 'www .jb51.net' requires a bucket of 13 characters,From the
Copy codeThe Code is as follows:DELIMITER $CREATEFUNCTION 't_gir'. 'func _ rand_string '(f_num tinyint unsigned, f_type tinyint unsigned)RETURNS varchar (32)BEGIN-- Translate the number to letter.-- No 1 stands for string only.-- No 2 stands for
Copy codeThe Code is as follows:How can I read 15 records randomly from the database?Order by rand () limit 0, 15How to read all records randomly from the database?Order by rand ()However, I checked the MYSQL official manual. The prompt for RAND ()
1. Create a user. // Log on to MYSQL@> Mysql-u root-p@> Password// Create a userMysql> insert into mysql. user (Host, User, Password, ssl_cipher, x509_issuer, x509_subJect) values ("localhost", "pppadmin", password ("passwd "),'','','');In this way,
There is a server with a large volume of access traffic. There are nearly 600 million dynamic PVS per day, and the database query average is nearly times per second.On the other server, the program is the same as this one, but only about dynamic PVS
If you want to give a specific user access from all machines in a given domain (for example, mydomain.com ), you can issue a GRANT statement that uses the '%' wildcard character in the host part of the account name:If you want a specific user to
PS: The following is a transfer. It is used to record that this is not the original intention of a regular expression, but it only uses REGEXP. Regular Expressions are more flexible and convenient.Replace sohu with sina in the author_url record of
When using mysql, you sometimes need to query records with unique fields. Although mysql provides the keyword distinct to filter out redundant duplicate records, only one record is retained, but it is often used to return the number of records that
MySQL supports two main table storage formats: MyISAM and InnoDB. InnoDB was used for a project last month. The results are very slow and only a dozen pieces can be inserted in one second. Later I changed to MyISAM format and inserted tens of
There are two different ways to add users: using the GRANT statement or directly operating the MySQL authorization table. The better way is to use the GRANT statement, because they are more concise and seem to have fewer errors.The following example
How to obtain the number of occurrences of a long string in SQLFor example, there is a string:
X-BGS-2010-09-15-001
I want to know the number of occurrences of '-', which can be implemented using the following method without complex one-Character
I found some information, and then I used the two functions concat () and left () in MySQL string processing ()1. CONCAT (str1, str2 ,...)Returns a string from the parameter link. If any parameter is NULL, return NULL. There can be more than two
(See )Assume that a UNION query is required. The first subquery is run as the branch first. If a matched row is found, the query of the second branch is no longer executed.
In general, we can write such a UNION query:Copy codeThe Code is as follows:
Status = show status like '%' [Example: show status like 'com _ select']Variables = show variables like '%' [Example: show variables like 'query _ cache_size ']
1. MySQL Query Count (status)Com_select; Com_update; Com_insert; Com_delete;
After installing the MySQL support library for Python, I encountered a series of problems at one time. Fortunately, Google solved them all. Record it and forget it.1. Download the Python MySQL support libraryAddress:
Create a trigger. The trigger creation syntax is as follows:
Create trigger trigger_name trigger_time trigger_event
ON tbl_name for each row trigger_stmt
Trigger_name indicates the trigger name, which you can specify;
Trigger_time indicates the
In SQL Structured Query Language, LIKE statements play a vital role.The syntax format of the LIKE statement is: select * from table name where field name like corresponding value (substring), which is mainly for struct fields, it is used to retrieve
In-depth analysis of MySQL database backup and restoration in Linux 1. Backup[Root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)[Root @ localhost mysql] # mysqldump-u
When using the following two methods, the field must be set to "primary key" or "UNIQUE constraint (UNIQUE )".1: Use replace into (This method uses the replacement method, which is a bit similar to deleting and then inserting)Copy codeThe Code is as
01#! /Bin/sh02# Code by scpman03# Function: Check and fix mysql database tables04# Add the script to the timer. When the script is executed, it will read the database, list all the tables to be repaired, timing them, and start fixing.05# The damaged
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