Recently, because of the need to study the MySQL random extraction implementation method. For example, to randomly extract a record from the TableName table, the general wording would be: SELECT * from TableName ORDER by RAND () LIMIT 1.
There are
My.ini in the MySQL directory, and then copied a my.ini on a colleague's machine to modify it and put it in a separate place as a backup. Its contents are as follows:
Copy Code code as follows:
#Uncomment or ADD only the keys, you
Learn PHP will have to mention MySQL, although there are phpmyadmin such tools can be graphical operation of the database, but I still want to learn PHP to use the command line to manipulate the database. Here's a summary of my studies, including
Create an index
MySQL creates the index syntax as follows:
CREATE [unique| Fulltext| SPATIAL] INDEX index_name
[USING Index_type] on
table_name (index_col_name,...)
The corresponding syntax variable information is as follows:
This paper analyzes the difference between create table as and like in MySQL. Share to everyone for your reference, specific as follows:
For MySQL copy the same table structure method, there are create table as and create table like two kinds, what
Deadlock (deadlock)
The so-called deadlock: refers to two or more than two processes in the implementation process, as a result of competing for resources caused by a mutual wait for the phenomenon, without external forces, they will not be able to
MySQL change data file storage path feel directly to the/etc/my.cnf in the DataDir to restart the service on the line, but search from the Internet more than n data, most of the changes in the My.cnf DataDir and sock and startup scripts/etc/rc.d/
PHP often through the following code, get the decision date of the SQL query statement
Copy Code code as follows:
$now = time (); Get the date of the current period
$sql = "SELECT * from ' the ' team ' where end_time> $now order by
Version 4.0 below, varchar (20), refers to 20 bytes, if stored UTF8 Chinese characters, can only save 6 (each Chinese character 3 bytes)
5.0 version above, varchar (20), refers to 20 characters, whether stored in numbers, letters or UTF8 characters (
The following is an example code that stores exception information in the log table when an exception occurs, and continues to run subsequent statements.
If you have any better suggestions, please do not hesitate to enlighten me.
Stored procedure
In simple terms, the master and slave copy of MySQL is a C/s architecture application. Master can be considered to be a client in our usual sense of server,slave. The I/O thread on the slave requests master data, and master verifies that the slave
Copy Code code as follows:
#创建触发器, when you add a record to the order table, update the goods table
Delimiter $
CREATE TRIGGER Trigger1
After INSERT on ' order '
For each ROW
BEGIN
UPDATE goods SET Num=num-new.much WHERE
To see if the event Scheduler is currently turned on
Show VARIABLES like ' Event_scheduler ';
Open Event Viewer
SET GLOBAL event_scheduler = 1;
Creating events
Grammar:
CREATE EVENT [IF not EXISTS] Event_Name
On SCHEDULE SCHEDULE
[on completion
MySQL's own mysqldump tool supports single-threaded work, exporting multiple tables in turn, without a parallel machine, which makes it impossible to quickly back up data.
Mydumper, as a utility, can support multithreaded work well, and can read
What is the difference between a clustered index and a nonclustered index in MySQL?
In MySQL, the InnoDB engine table is the (clustered) Index organization table (clustered index organize), and the MyISAM engine table is the heap organization table
Today, there is a MySQL database on the server, remote access, do not want to disclose the root account, so, create a demo account, allow demo account anywhere can access the MySQL database Shandong Library.
programme I:
Running on a
1, the method of declaring the primary key:You can add a primary key to a table when you create it, such as:CREATE TABLE tbl_name ([Field description omitted ...], PRIMARY KEY (index_col_name));You can also add a primary key to a table when you
Now to introduce the MySQL command line, from the establishment of the database to the table data delete the whole process, I hope to help.
Login MySQL
Play cmd command terminal, if you have added a MySQL environment variable, you can directly use
Windows can use the bat batch file to back up the MySQL operation, when the general data volume of the backup can be used to copy the file, but this way requires server downtime or stop writing commands, not used. If the data is small, it is
Locate the My.ini file in the MySQL installation directory and add the following code:
Interactive_timeout = 120
Wait_timeout = 120
Max_allowed_packet = 32M
======================================
Small example
Mytest_emp_dept.sql file, which reads
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