The use of the group by function should be that each column specified in the SELECT list must also appear in the group by clause, unless this column is used for Aggregate functions, but today I was surprised to help my colleagues debug a group by
1. Randomly query a piece of data
Method 1: SELECT * FROM 'table' order by rand () limit 1
Rating: it is not recommended and the efficiency is very low. It is described in the official document that Order By and RAND () can be used to scan the table
1. Add a user
Copy codeThe Code is as follows:Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "lionbule", password ("hello1234 "));Mysql> flush privileges;
2. Change the User Password
Copy codeThe Code is as follows:Mysql>
The first phase of basic knowledge about MySQL: How to remotely access the MySQL database and how to set permissions. This section discusses how to access a single database, all databases, specify user access, set access passwords, and specify
1. left function, used to intercept the string content of the query field. select left (content, 50) as summary from article; here, it means to query only the first 50 characters of the content column. Here, Chinese characters are also considered as
Normal Syntax:Copy codeThe Code is as follows:Select * from table_name t where t. field1 in (1, 2, 3, 4 ,...); When the list in the write stored procedure in is substituted with an input parameter, the following method is required:The find_in_set
1. The most common paging Method for MYSQL:Copy codeThe Code is as follows:Select * from content order by id desc limit 0, 10In the case of small data volumes, such SQL statements are enough. The only problem that needs to be paid attention is that
When using the Insert Select statement to Insert a record, you must follow the following principles.When selecting data using the Select statement, you cannot Select rows from the table to which the data is inserted.The number of fields in the
1. Modify the localization timePrinciple: gettext is required to format the localization time. If this function is not enabled in your environment, garbled characters are returned, affecting the processing of phpmyadmin ajax. this test is passed in
Method 1:The best way is to change the float field to decimal (16, 6 ). Specific Method: you can set a temporary field and accurately copy it with the MySQL keyword binary.Method 2:Use the binary keyword. The specific operation is "select sum
MySQL databases are IO-intensive programs. Like other databases, their main functions are data persistence and data management. This article focuses on optimizing MySQL database cache parameters such as query cache, table cache, log cache, index
Due to the adjustment of the company's business and application, many tables in Mysql are not needed before, so we need to sort out the database.
At the beginning, I was wondering: Will some tables be deleted? A good solution. Just write a simple
1, mysql-connector-java-5.0.4-bin.jar into C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ lib
2. The project's web. xml is consistent with tomcat
webt3 index.jsp Tomcat 7
1. Phantom read. Many books and blogs have mentioned that mysql tx_isolate (transaction isolation) is repeatable read. Mysql does next-key lock to prevent phantom read. However, if you use
SELECT * from [table];
SELECT * from [table] for
Summarize the optimization methods of common query statements.1 COUNT
1. Functions of COUNT
· COUNT (table. filed) indicates the number of records for which this field is not null.
· COUNT (*) or COUNT (not nullable field) indicates the number of
1. Create a table:
// Overwrite the index create table if not exists 'ben' ('A' int (10) unsigned not null AUTO_INCREMENT, 'bb' int (10) unsigned not null, 'cc' varchar (100) not null, primary key ('A'), KEY 'bar' ('bb ', 'A') ENGINE = MyISAM; // No
We often forget the mysql password and may need to modify it.
Record the test results of how Baidu modified the mysql password:1. Add a line after the configuration file mysql. ini:
Skip-grant-tablesIndicates skipping the authorization table.
Problem SQL Background: if the project has six tables, the corresponding brand_id field should be written according to the pid field. However, there are two tables of tens of millions. After my worker is running, the online mysql master-slave
Translated by: Tie
Time: December 25, 2013Original article address: Activating the Binary Log
Reference: building a robust data center with high-availability MySQL
To enable the binary log feature, you can use"
-- Log-bin [= name]"Option to start
The purpose of indexing is to greatly improve query efficiency and read/write efficiency.
Kettle inserts data into the SQL statement. indexes must be created during the update, which greatly improves the processing time.
However, when an index is
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