The following content is excerpted from [1]
A primary key does not have a clear concept definition. It is an index and a unique index. It must be defined as a "primary key" and cannot be repeated, A table can have only one primary key.
1.
1. Query the SELECT query statement execution plan using explainMysql> select * from baba where name = ' FJDSJF ';+------+--------+| ID | name |+------+--------+| 1 | FJDSJF |+------+--------+Query the execution plan for the SQL statementMysql>
Mysql ignores primary key conflicts and prevents repeated insertion of bitsCN.com
Several ways for mysql to ignore primary key conflicts and avoid repeated inserts
Solution 1: Use the ignore keyword
Solution 2: Use replace
Solution 3: ON DUPLICATE
High-Performance MySql evolution (11): Optimization of common query statements bitsCN.com
Summarize the optimization methods of common query statements.1 COUNT
1. Functions of COUNT
· COUNT (table. filed) indicates the number of records for which
1. Use RAND () to extract random rows in MySQL. The method for generating random numbers is the RAND () function. You can use this function together with the order by clause to perform random row extraction. The principle is that order by rand ()
Group by statementThe group by statement is used in combination with the aggregate function to GROUP result sets based on one or more columns.
SQL GROUP BY syntaxSELECT column_name, aggregate_function (column_name)FROM table_nameWHERE column_name
For errors"
Incorrect string value: '\ xe6 \ xa2 \ xb5 \ xe8 \ x92 \ x82...' for column 'object _ repr' at Row 1
The solution is to set object_repr of the django_admin_log table to use utf8_unicode_ci;
For error "incorrect string value: '\ xe6 \
MySQL APIs have functions:
Insert (STR, POs, Len, newstr)
Returns the STR string. Its substring starts from the POs position and is long replaced by the string newstr. If the POs length exceeds the string length, the return value is the
I haven't written a program for a long time. I am ready to start work. I have to use databases in some places. After careful consideration, I still want to use open-source MySql. Although MSSQL and Access are good, however, I have heard of the great
Document directory
7.2.2 estimate query performance
7.2.2 estimate query performance
In most cases, you can estimate the query performance by counting the number of disk searches. For small tables, you usually only need to search a disk once
Mysql alter statement usage, adding, modifying, and deleting Fields
// Primary key
Alter table tabelname add new_field_id int (5) unsigned default 0 not null auto_increment, add primary key (new_field_id );
// Add a new column
Alter table t2 add d
MySql avoids repeated insert recordsPublished on: December 15,201 1, pm: MySQL Author: Cyrec read: [308]
Today, we need to avoid repeated data insertion when capturing data in the database using python. We have found some methods on the
How to Implement the isnull function in mssql in mysql
========================================================== ============
IFNULL (expr1, expr2)If expr1 is not NULL, the returned value of IFNULL () is expr1;Otherwise, the returned value is expr2.
Overview:The case statement in the SQL statement and switch statement in the advanced language are standard SQL syntaxes and are applicable to multiple condition judgments.
In case of different values, perform different operations.
First, let's take
/Usr/bin/mysqladmin: connect to server at 'localhost' failed
Error: 'Can't connect to local MySQL server through socket '/var/run/mysqld. Sock' (2)
Check that mysqld is running and that the socket: '/var/run/mysqld. Sock' exists
1. What is an index?
Indexes are used to quickly search for records with specific values. All MySQL indexes are saved as B-trees. If no index exists, MySQL must scan all the records of the entire table from the first record until the required
(1)
Reduce Database Access Static pages are possible Static parts of a dynamic page Some data can be generated as XML or saved as text files Use data caching technology, such as memcached (2)Optimization Detection Method 1. User Experience
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.