In databases, we often encounter the following situation: A primary table A, A subtable B, and table B contain the primary key of Table A as the foreign key. When you want to insert data, we will first insert Table A, then obtain the Identity of
MySQL is a very popular small relational database management system. Currently, MySQL is widely used in small and medium websites on the Internet. Because of its small size, fast speed, and low total cost of ownership, especially the open source
Fault status: the php website fails to connect to mysql. However, you can use the mysql command in the command line to log on and operate normally.Solution:1. log on to mysql under the command line and execute the following command:Copy codeThe Code
If you forget the MySQL root Password, You can reset it using the following methods:
1. KILL the MySQL process in the system;
2. Run the following command to start MySQL without checking its permissions;
Mysqld_safe-skip-grant-tables &
3. Use
1. Official documentsThe following excerpt describes utf8_unicode_ci and utf8_general_ci In the Mysql 5.1 Chinese manual:Copy codeThe Code is as follows:Currently, utf8_unicode_ci rules only support Unicode rules. Some characters are not supported.
In mysql, If we select to directly use in command mode and switch to the database, we can select mysql_select_db for data in php. I will introduce it below.
From the command prompt, select MySQL database:
This is very easy to choose a specific
1. Aggregate functions
Aggregate functions are functions that run on a row group to calculate and return a single value.
SQL Aggregate functions
Function
Description
AVG ()
Returns the average value of a column.
This is the third article on MySQL SQL optimization. A company's business system frequently throws a problematic SQL statement. We have made fundamental statistics on such SQL statements:
These SQL statements have been executed for 12 times
In the past few days, I will share and summarize some SQL experience optimized in the past few days. The first thing to share is to optimize the limit page for MyISAM. Background: A business system provided by the company to crawlers to capture data.
There are two major steps to enable the MySQL remote login account:
1. Check whether the firewall on the server does not block port 3306.
The default port of MySQL is 3306. Make sure that the firewall does not block port 3306. Otherwise, the remote
When you work on a very large table, you may occasionally need to run many queries to obtain a small subset of a large amount of data, instead of running these queries on the entire table, instead, MySQL can find a few required records each time,
Here, the blog simply aims to extract some common mysql operations. If you already understand this, you can ignore it. Thank you.Basic mysql operations
1. query mysql version and current time information
Select version (), current_date,
The SYS_CONNECT_BY_PATH function in oracle facilitates development. How does mysql implement similar functions?
DELIMITER $Create function 'getparentlist' (rootId VARCHAR (50) returns varchar (1000)
BEGIN
DECLARE sParentList VARCHAR (1000 );
1. Functions
Function portability is not very strong. Different DBMS has different functions.
2. Text processing functions
Function
Description
Left ()
Returns the character on the left of the string.
1. Fields
Fields are similar to column meanings. Database columns are generally called columns, and fields are generally calculated fields.2. Splice Fields
Join -- connect values together to form a single value
Concat () function
SELECT Concat
When updating a table using mysql workbench, the following exception is reported:
Error Code: 1175. To disable safe mode, toggle the option in Preferences-> SQL Editor-> Query Editor and reconnect.
You are using safe update mode and you tried to
At the early stage of the project design, I had the idea that, at the same time, I chose the final nosql solution to meet the following conditions:
1. Frequent demand changes: development must be more agile, development costs and maintenance costs
1. Create Table
Create table (
Name char (20) not null,
Id char (20) not null primary key );
2. Create Table B
Create table B (
B _name char (20) not null,
B _id char (20) not null,
Constraint foreign key (B _id) references a (id) on delete
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.