Generally, secondary indexes are used for count:For example, if ID is PK aid, it is secondary index.
Use
CopyCodeThe Code is as follows: Select count (*) from table where ID> = 0;
Or
Select count (*) from table;
The results are the same. PK
The basic process of mysqld_safe script execution:1. Search for basedir and ledir.2. Search for datadir and my. cnf.3. Check my. cnf. For details about the options, see the annotations in the attachment.4. parse the groups [mysqld] and [mysqld_safe]
After getting started with replication, I began to think about how to configure and try it. Although there were a lot of problems: I had to check the information on the Internet and finally solved some problems. now I will share my experiences:The
Select * from table limit m, n where m Refers to the index at the beginning of the record, starting from 0, and n refers to taking n records starting from entry m.
Copy codeThe Code is as follows: mysql (root @ localhost: test)> select * from total;
When I interviewed mysqldba, I encountered a question:
Describes the implementation principle of the msyql replication mechanism. How can I restore the database node of the slave with inconsistent data without stopping the mysql master
DAYOFWEEK (date)
Returns the index of the week of the date (1 = Sunday, 2 = Monday ,...... 7 = Saturday ). These index values correspond to the ODBC standard.Mysql> select DAYOFWEEK ('2017-02-03 ');-> 3
WEEKDAY (date) Returns the week index of date (
1. mysql transactions
In MYSQL, only INNODB Data Tables support transaction processing.
There are two ways to start a transaction:
(1)Use begin, rollback, and commit to implement
Copy codeThe Code is as follows: begin starts a transaction
Rollback
Mysql can use operators to perform operations on data in tables, such as age calculation by birth date.
Operators include Arithmetic Operators, comparison operators, logical operators, and bitwise operators.
Arithmetic OperatorsAddition, subtraction,
Data is very important. I want to know this with my toes. To ensure data security, we need to regularly back up data.
Here are some notes about data backup and restoration.
Data backup use the mysqldump command to back up a database
mysqldump -u
I learned from manual that the mysql_affected_rows function will return abnormal values when the data before and after UPDATE is the same,
The following is a convenient solution. The bdobrica at gmail dot com message is displayed on the official
This is a good mysql database optimization article I have seen on the Internet. The content is full!
1. Use indexes to traverse tables faster
The index created by default is a non-clustered index, but sometimes it is not optimal. In a
Assume that the Status field of a data table is of the varchar type and has the following values: NULL, pending, pending refund, refund, and cancel.
We know the order whose query status is cancel. The SQL statement can be written as follows: SELECT
Mysql uses a trigger to synchronize two tables
Currently, the local test is successful.
Assume that two local databases a and B have table1 (id, val) and table2 (id, val) in table)
Assume that you want to synchronize data updates in table 1 and
Find the my. ini file in the mysql installation directory and add the following code:
Interactive_timeout = 120
Wait_timeout = 120
Max_allowed_packet = 32 M
==============================================
Small Example
The mytest_emp_dept. SQL
Mysql database startup Error:
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
100224 12:24:20 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB:
1. The premise is that MyEclipse can normally develop Java Projects
2. Install MySQL
Personally, the version is mysql-5.0.22-win32.zip.
Web: http://www.mysql.com/downloads/mysql/#downloads
3. Download The JDBC driver
I personally use
First stop the mysql service:
Copy codeThe Code is as follows: root @ webserver:/home/webmaster # service mysql stop
Then, a new mysql service is created in the ignore Password Authentication Mode:Copy codeThe Code is as follows: root @
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