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
Copy Code code as follows:
One
DECLARE @s varchar (20)
DECLARE @i varchar (20)
Set @i= '
Set @s= ' new member must purchase 350 Yuan product '
While PATINDEX ('%[0-9]% ', @s) >0
Begin
Set @i=@i+substring (@s,patindex ('%[0-9]%
In contrast, the first is to use the MySQL stored procedures to get:
Copy Code code as follows:
Mysql>delimiter $
Mysql>set autocommit = 0$$
Mysql> CREATE PROCEDURE Test ()
Begin
Declare i decimal (a) default 0;
Dd:loop
Now use the two servers have been installed MySQL, are all rpm packaging, can be used normally.
In order to avoid unnecessary trouble, master server MySQL version as much as possible to maintain consistency;
Environment: 192.168.0.1 (Master)
192.168.
For large databases, it is very quick to load the data into a table with no Fulltext index and then use ALTER table (or CREATE index) to create the index. It will be very slow to load data into a table that already has a fulltext index.
1.
Need to open a slow query output of an organ: log_slow_queries. Can be set in the MySQL configuration file (my.ini/my.cnf) or through the MySQL client temporary settings. The advantage of the second approach is that you can take the settings into
The example in this article describes the method of thinkphp3.x connecting to the MySQL database. Share to everyone for your reference, specific as follows:
Formula Profile: thinkphp/conf/convention.php
(1) Fill in the configuration file in the
Copy Code code as follows:
@mysql_connect ("localhost", "root", "1981427")//Select database before you need to connect to the database server
Or Die ("Database server Connection Failed");
$dbs = Mysql_list_dbs (); Calling the Mysql_list_
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
From child querysubqueries in the FROM clauseThe MySQL from subquery refers to the FROM clause as a subquery statement, and the main query to the subquery results to obtain the required data. The FROM subquery syntax is as follows:
SELECT ...
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
For example: Select (A+b) as C from table
Types are also varchar type, but they are not displayed correctly.
Until Concat ()
concat function in MySQL
The following is an example of how to use the Concat function in MySQL, such as select Concat ('
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 Query Cachethe effect of query caching is that when a query receives a query that is the same as before, the server retrieves the results from the query cache, rather than parsing and executing the last query again. This greatly improves
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
I. Overview
This chapter mainly writes how to generate a new slow query file online when the slow query file is very large.
Test environment: MySQL 5.6.21
Second, the steps
Configure a slow query
The default my.cnf file is in the/etc/directory
The MySQL caching mechanism is simply caching SQL text and query results, and if you run the same SQL, the server takes the results directly from the cache without having to parse and execute the SQL. If the table changes, all buffered queries that
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
Inserting datainserts into the SQL statement in the MySQL table to insert the data.You can insert data into a datasheet via the mysql> Command Prompt window, or insert data through PHP scripts.GrammarThe following is a generic insert into SQL syntax
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
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