Inhaltsverzeichnis
1 Der Wert der Typspalte in der EXPLAIN-Anweisung
2, Beispiel für einen Verbindungstyp
2, Verbindungstyp-Teilbeispiel
Heim Datenbank MySQL-Tutorial Beispiel für MySQL-Verbindungstypen

Beispiel für MySQL-Verbindungstypen

Feb 13, 2017 am 10:57 AM
mysql


Um den MySQL-Ausführungsplan zu erhalten, können wir ihn über die EXPLAIN-Methode anzeigen. Die EXPLAIN-Methode scheint einfach zu sein, enthält aber tatsächlich viel Inhalt, insbesondere den Typ das Ausgabeergebnis. Das Verständnis dieser verschiedenen Typen ist für unsere SQL-Optimierung sehr wichtig. In diesem Artikel wird nur die Typspalte in den Explian-Ausgabeergebnissen beschrieben und demonstriert.

Eine vollständige Beschreibung der Explian-Ausgabe finden Sie unter: MySQL EXPLAIN SQL-Ausgabeinformationsbeschreibung

1 Der Wert der Typspalte in der EXPLAIN-Anweisung

type:
    连接类型
    system          表只有一行    const           表最多只有一行匹配,通用用于主键或者唯一索引比较时
    eq_ref          每次与之前的表合并行都只在该表读取一行,这是除了system,const之外最好的一种,
                    特点是使用=,而且索引的所有部分都参与join且索引是主键或非空唯一键的索引
    ref             如果每次只匹配少数行,那就是比较好的一种,使用=或<=>,可以是左覆盖索引或非主键或非唯一键
    fulltext        全文搜索
    ref_or_null     与ref类似,但包括NULL
    index_merge     表示出现了索引合并优化(包括交集,并集以及交集之间的并集),但不包括跨表和全文索引。
                    这个比较复杂,目前的理解是合并单表的范围索引扫描(如果成本估算比普通的range要更优的话)
    unique_subquery 在in子查询中,就是value in (select...)把形如“select unique_key_column”的子查询替换。
                    PS:所以不一定in子句中使用子查询就是低效的!
    index_subquery  同上,但把形如”select non_unique_key_column“的子查询替换
    range           常数值的范围    index           a.当查询是索引覆盖的,即所有数据均可从索引树获取的时候(Extra中有Using Index);
                    b.以索引顺序从索引中查找数据行的全表扫描(无 Using Index);
                    c.如果Extra中Using Index与Using Where同时出现的话,则是利用索引查找键值的意思;
                    d.如单独出现,则是用读索引来代替读行,但不用于查找
    all             全表扫描
Nach dem Login kopieren
Nach dem Login kopieren

2, Beispiel für einen Verbindungstyp

1、all-- 环境描述
(root@localhost) [sakila]> show variables like &#39;version&#39;;
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| version       | 5.6.26 |
+---------------+--------+
MySQL采取全表遍历的方式来返回数据行,等同于Oracle的full table scan
(root@localhost) [sakila]> explain select count(description) from film;
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
|  1 | SIMPLE      | film  | ALL  | NULL          | NULL | NULL    | NULL | 1000 | NULL  |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
2、index
MySQL采取索引全扫描的方式来返回数据行,等同于Oracle的full index scan
(root@localhost) [sakila]> explain select title from film \G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: film         
type: indexpossible_keys: NULL
          key: idx_title      
          key_len: 767          
          ref: NULL         
          rows: 1000        
          Extra: Using index1 row in set (0.00 sec)

3、  range
索引范围扫描,对索引的扫描开始于某一点,返回匹配值域的行,常见于between、<、>等的查询
等同于Oracle的index range scan
(root@localhost) [sakila]> explain select * from payment where customer_id>300 and customer_id<400\G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: payment         
type: rangepossible_keys: idx_fk_customer_id          
key: idx_fk_customer_id      
key_len: 2          
ref: NULL         
rows: 2637        
Extra: Using where1 row in set (0.00 sec)

(root@localhost) [sakila]> explain select * from payment where customer_id in (200,300,400)\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE        
  table: payment         
  type: rangepossible_keys: idx_fk_customer_id          
  key: idx_fk_customer_id      
  key_len: 2          
  ref: NULL         
  rows: 86        
  Extra: Using index condition1 row in set (0.00 sec)

4、ref
非唯一性索引扫描或者,返回匹配某个单独值的所有行。常见于使用非唯一索引即唯一索引的非唯一前缀进行的查找
(root@localhost) [sakila]> explain select * from payment where customer_id=305\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE        
  table: payment         
  type: refpossible_keys: idx_fk_customer_id          
  key: idx_fk_customer_id      
  key_len: 2          
  ref: const         
  rows: 25        
  Extra: 1 row in set (0.00 sec)

idx_fk_customer_id为表payment上的外键索引,且存在多个不不唯一的值,如下查询
(root@localhost) [sakila]> select customer_id,count(*) from payment group by customer_id
    -> limit 2;
+-------------+----------+
| customer_id | count(*) |+-------------+----------+
|           1 |       32 ||           2 |       27 |
+-------------+----------+-- 下面是非唯一前缀索引使用ref的示例
(root@localhost) [sakila]> create index idx_fisrt_last_name on customer(first_name,last_name);
Query OK, 599 rows affected (0.09 sec)
Records: 599  Duplicates: 0  Warnings: 0(root@localhost) [sakila]> select first_name,count(*) from customer group by first_name 
    -> having count(*)>1 limit 2;
+------------+----------+| first_name | count(*) |
+------------+----------+| JAMIE      |        2 || JESSIE     |        2 |
+------------+----------+2 rows in set (0.00 sec)

(root@localhost) [sakila]> explain select first_name from customer where first_name=&#39;JESSIE&#39;\G
*************************** 1. row ***************************           
id: 1  select_type: SIMPLE        
table: customer         
type: refpossible_keys: idx_fisrt_last_name          
key: idx_fisrt_last_name      
key_len: 137          
ref: const         
rows: 2        
Extra: Using where; Using index1 row in set (0.00 sec)

(root@localhost) [sakila]> alter table customer drop index idx_fisrt_last_name;
Query OK, 599 rows affected (0.03 sec)
Records: 599  Duplicates: 0  Warnings: 0--下面演示出现在join是ref的示例
(root@localhost) [sakila]> explain select b.*,a.* from payment a inner join    -> customer b on a.customer_id=b.customer_id\G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: b         
type: ALLpossible_keys: PRIMARY
          key: NULL
      key_len: NULL          
      ref: NULL         
      rows: 599        
      Extra: NULL
      *************************** 2. row ***************************           
      id: 1  
      select_type: SIMPLE        
      table: a         
      type: refpossible_keys: idx_fk_customer_id          
      key: idx_fk_customer_id      
      key_len: 2          
      ref: sakila.b.customer_id         
      rows: 13        
      Extra: NULL2 rows in set (0.01 sec)

5、eq_ref
类似于ref,其差别在于使用的索引为唯一索引,对于每个索引键值,表中只有一条记录与之匹配。
多见于主键扫描或者索引唯一扫描。
(root@localhost) [sakila]> explain select * from film a join film_text b 
    -> on a.film_id=b.film_id;
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref         | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
|  1 | SIMPLE      | b     | ALL    | PRIMARY       | NULL    | NULL    | NULL    | 1000 | NULL    |
|  1 | SIMPLE      | a     | eq_ref | PRIMARY       | PRIMARY | 2       | sakila.b.film_id |    1 | Using where |
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
(root@localhost) [sakila]> explain select title from film where film_id=5;
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+|  1 | SIMPLE      
| film  | const | PRIMAR   | PRIMARY | 2       | const |    1 | NULL  |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+6、const、system:
当MySQL对查询某部分进行优化,这个匹配的行的其他列值可以转换为一个常量来处理。
如将主键或者唯一索引置于where列表中,MySQL就能将该查询转换为一个常量
(root@localhost) [sakila]> create table t1(id int,ename varchar(20) unique);
Query OK, 0 rows affected (0.05 sec)

(root@localhost) [sakila]> insert into t1 values(1,&#39;robin&#39;),(2,&#39;jack&#39;),(3,&#39;henry&#39;);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

(root@localhost) [sakila]> explain select * from (select * from t1 where ename=&#39;robin&#39;)x;
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+
| id | select_type | table      | type   | possible_keys | key   | key_len | ref   | rows | Extra |
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+
|  1 | PRIMARY     | <derived2> | system | NULL          | NULL  | NULL    | NULL  |    1 | NULL  |
|  2 | DERIVED     | t1         | const  | ename         | ename | 23      | const |    1 | NULL  |
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+
2 rows in set (0.00 sec)

7、type=NULL
MySQL不用访问表或者索引就可以直接得到结果
(root@localhost) [sakila]> explain select sysdate();+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
|  1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | No tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)
Nach dem Login kopieren


Um den MySQL-Ausführungsplan zu erhalten, können wir ihn über die EXPLAIN-Methode anzeigen Scheint einfach zu sein, enthält aber tatsächlich viel Inhalt, insbesondere die Typspalte im Ausgabeergebnis. Das Verständnis dieser verschiedenen Typen ist für unsere SQL-Optimierung sehr wichtig. In diesem Artikel wird nur die Typspalte in den Explian-Ausgabeergebnissen beschrieben und demonstriert.

Eine vollständige Beschreibung der Explian-Ausgabe finden Sie unter: MySQL EXPLAIN SQL-Ausgabeinformationsbeschreibung

1 Der Wert der Typspalte in der EXPLAIN-Anweisung

type:
    连接类型
    system          表只有一行    const           表最多只有一行匹配,通用用于主键或者唯一索引比较时
    eq_ref          每次与之前的表合并行都只在该表读取一行,这是除了system,const之外最好的一种,
                    特点是使用=,而且索引的所有部分都参与join且索引是主键或非空唯一键的索引
    ref             如果每次只匹配少数行,那就是比较好的一种,使用=或<=>,可以是左覆盖索引或非主键或非唯一键
    fulltext        全文搜索
    ref_or_null     与ref类似,但包括NULL
    index_merge     表示出现了索引合并优化(包括交集,并集以及交集之间的并集),但不包括跨表和全文索引。
                    这个比较复杂,目前的理解是合并单表的范围索引扫描(如果成本估算比普通的range要更优的话)
    unique_subquery 在in子查询中,就是value in (select...)把形如“select unique_key_column”的子查询替换。
                    PS:所以不一定in子句中使用子查询就是低效的!
    index_subquery  同上,但把形如”select non_unique_key_column“的子查询替换
    range           常数值的范围    index           a.当查询是索引覆盖的,即所有数据均可从索引树获取的时候(Extra中有Using Index);
                    b.以索引顺序从索引中查找数据行的全表扫描(无 Using Index);
                    c.如果Extra中Using Index与Using Where同时出现的话,则是利用索引查找键值的意思;
                    d.如单独出现,则是用读索引来代替读行,但不用于查找
    all             全表扫描
Nach dem Login kopieren
Nach dem Login kopieren

2, Verbindungstyp-Teilbeispiel

1、all-- 环境描述
(root@localhost) [sakila]> show variables like &#39;version&#39;;
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| version       | 5.6.26 |
+---------------+--------+MySQL采取全表遍历的方式来返回数据行,等同于Oracle的full table scan
(root@localhost) [sakila]> explain select count(description) from film;
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
|  1 | SIMPLE      | film  | ALL  | NULL          | NULL | NULL    | NULL | 1000 | NULL  |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
2、index
MySQL采取索引全扫描的方式来返回数据行,等同于Oracle的full index scan
(root@localhost) [sakila]> explain select title from film \G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: film         
type: indexpossible_keys: NULL
          key: idx_title      
          key_len: 767          
          ref: NULL         
          rows: 1000        
          Extra: Using index1 row in set (0.00 sec)

3、  range
索引范围扫描,对索引的扫描开始于某一点,返回匹配值域的行,常见于between、<、>等的查询
等同于Oracle的index range scan
(root@localhost) [sakila]> explain select * from payment where customer_id>300 and customer_id<400\G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: payment         
type: rangepossible_keys: idx_fk_customer_id          
key: idx_fk_customer_id      
key_len: 2          
ref: NULL         
rows: 2637        
Extra: Using where1 row in set (0.00 sec)

(root@localhost) [sakila]> explain select * from payment where customer_id in (200,300,400)\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE        
  table: payment         
  type: rangepossible_keys: idx_fk_customer_id          
  key: idx_fk_customer_id      
  key_len: 2          
  ref: NULL         
  rows: 86        
  Extra: Using index condition1 row in set (0.00 sec)

4、ref
非唯一性索引扫描或者,返回匹配某个单独值的所有行。常见于使用非唯一索引即唯一索引的非唯一前缀进行的查找
(root@localhost) [sakila]> explain select * from payment where customer_id=305\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE        
  table: payment         
  type: refpossible_keys: idx_fk_customer_id          
  key: idx_fk_customer_id      
  key_len: 2          
  ref: const         
  rows: 25        
  Extra: 1 row in set (0.00 sec)

idx_fk_customer_id为表payment上的外键索引,且存在多个不不唯一的值,如下查询
(root@localhost) [sakila]> select customer_id,count(*) from payment group by customer_id
    -> limit 2;
+-------------+----------+
| customer_id | count(*) |+-------------+----------+
|           1 |       32 ||           2 |       27 |
+-------------+----------+-- 下面是非唯一前缀索引使用ref的示例
(root@localhost) [sakila]> create index idx_fisrt_last_name on customer(first_name,last_name);
Query OK, 599 rows affected (0.09 sec)
Records: 599  Duplicates: 0  Warnings: 0(root@localhost) [sakila]> select first_name,count(*) from customer group by first_name 
    -> having count(*)>1 limit 2;
+------------+----------+| first_name | count(*) |
+------------+----------+| JAMIE      |        2 || JESSIE     |        2 |
+------------+----------+2 rows in set (0.00 sec)

(root@localhost) [sakila]> explain select first_name from customer where first_name=&#39;JESSIE&#39;\G
*************************** 1. row ***************************           
id: 1  
select_type: SIMPLE        
table: customer         
type: refpossible_keys: idx_fisrt_last_name          
key: idx_fisrt_last_name      
key_len: 137          
ref: const         
rows: 2        
Extra: Using where; Using index1 row in set (0.00 sec)

(root@localhost) [sakila]> alter table customer drop index idx_fisrt_last_name;
Query OK, 599 rows affected (0.03 sec)
Records: 599  Duplicates: 0  Warnings: 0--下面演示出现在join是ref的示例
(root@localhost) [sakila]> explain select b.*,a.* from payment a inner join    
-> customer b on a.customer_id=b.customer_id\G
*************************** 1. row ***************************           
id: 1  
select_type: 
SIMPLE        
table: b         
type: ALLpossible_keys: PRIMARY
          key: NULL
      key_len: NULL          
      ref: NULL         
      rows: 599        
      Extra: NULL
      *************************** 2. row ***************************           
      id: 1  
      select_type: SIMPLE        
      table: a         
      type: refpossible_keys: idx_fk_customer_id          
      key: idx_fk_customer_id      
      key_len: 2          
      ref: sakila.b.customer_id         
      rows: 13        
      Extra: NULL2 rows in set (0.01 sec)

5、eq_ref
类似于ref,其差别在于使用的索引为唯一索引,对于每个索引键值,表中只有一条记录与之匹配。
多见于主键扫描或者索引唯一扫描。
(root@localhost) [sakila]> explain select * from film a join film_text b 
    -> on a.film_id=b.film_id;
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref              | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
|  1 | SIMPLE      | b     | ALL    | PRIMARY       | NULL    | NULL    | NULL          | 1000 | NULL   |
|  1 | SIMPLE      | a     | eq_ref | PRIMARY       | PRIMARY | 2       | sakila.b.film_id |    1 | Using where |
+----+-------------+-------+--------+---------------+---------+---------+------------------+------+-------------+
(root@localhost) [sakila]> explain select title from film where film_id=5;
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
|  1 | SIMPLE      | film  | const | PRIMARY       | PRIMARY | 2       | const |    1 | NULL  |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
6、const、system:
当MySQL对查询某部分进行优化,这个匹配的行的其他列值可以转换为一个常量来处理。
如将主键或者唯一索引置于where列表中,MySQL就能将该查询转换为一个常量
(root@localhost) [sakila]> create table t1(id int,ename varchar(20) unique);
Query OK, 0 rows affected (0.05 sec)

(root@localhost) [sakila]> insert into t1 values(1,&#39;robin&#39;),(2,&#39;jack&#39;),(3,&#39;henry&#39;);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

(root@localhost) [sakila]> explain select * from (select * from t1 where ename=&#39;robin&#39;)x;
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+
| id | select_type | table      | type   | possible_keys | key   | key_len | ref   | rows | Extra |
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+|  
1 | PRIMARY     | <derived2> | system | NULL          | NULL  | NULL    | NULL  |    1 | NULL  ||  
2 | DERIVED     | t1         | const  | ename         | ename | 2
3      | const |    1 | NULL  |
+----+-------------+------------+--------+---------------+-------+---------+-------+------+-------+
2 rows in set (0.00 sec)

7、type=NULL
MySQL不用访问表或者索引就可以直接得到结果
(root@localhost) [sakila]> explain select sysdate();
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
|  1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | No tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)
Nach dem Login kopieren

Das Obige ist der Inhalt des Beispiels für den MySQL-Verbindungstyp. Weitere verwandte Inhalte finden Sie auf der chinesischen PHP-Website (www.php. cn)!

Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat -Befehle und wie man sie benutzt
1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

MySQL: Einfache Konzepte für einfaches Lernen MySQL: Einfache Konzepte für einfaches Lernen Apr 10, 2025 am 09:29 AM

MySQL ist ein Open Source Relational Database Management System. 1) Datenbank und Tabellen erstellen: Verwenden Sie die Befehle erstellte und creatEtable. 2) Grundlegende Vorgänge: Einfügen, aktualisieren, löschen und auswählen. 3) Fortgeschrittene Operationen: Join-, Unterabfrage- und Transaktionsverarbeitung. 4) Debugging -Fähigkeiten: Syntax, Datentyp und Berechtigungen überprüfen. 5) Optimierungsvorschläge: Verwenden Sie Indizes, vermeiden Sie ausgewählt* und verwenden Sie Transaktionen.

Wie man phpmyadmin öffnet Wie man phpmyadmin öffnet Apr 10, 2025 pm 10:51 PM

Sie können PhpMyAdmin in den folgenden Schritten öffnen: 1. Melden Sie sich beim Website -Bedienfeld an; 2. Finden und klicken Sie auf das Symbol phpmyadmin. 3. Geben Sie MySQL -Anmeldeinformationen ein; 4. Klicken Sie auf "Login".

So erstellen Sie Navicat Premium So erstellen Sie Navicat Premium Apr 09, 2025 am 07:09 AM

Erstellen Sie eine Datenbank mit Navicat Premium: Stellen Sie eine Verbindung zum Datenbankserver her und geben Sie die Verbindungsparameter ein. Klicken Sie mit der rechten Maustaste auf den Server und wählen Sie Datenbank erstellen. Geben Sie den Namen der neuen Datenbank und den angegebenen Zeichensatz und die angegebene Kollektion ein. Stellen Sie eine Verbindung zur neuen Datenbank her und erstellen Sie die Tabelle im Objektbrowser. Klicken Sie mit der rechten Maustaste auf die Tabelle und wählen Sie Daten einfügen, um die Daten einzufügen.

So erstellen Sie eine neue Verbindung zu MySQL in Navicat So erstellen Sie eine neue Verbindung zu MySQL in Navicat Apr 09, 2025 am 07:21 AM

Sie können eine neue MySQL -Verbindung in Navicat erstellen, indem Sie den Schritten folgen: Öffnen Sie die Anwendung und wählen Sie eine neue Verbindung (Strg N). Wählen Sie "MySQL" als Verbindungstyp. Geben Sie die Hostname/IP -Adresse, den Port, den Benutzernamen und das Passwort ein. (Optional) Konfigurieren Sie erweiterte Optionen. Speichern Sie die Verbindung und geben Sie den Verbindungsnamen ein.

MySQL: Eine Einführung in die beliebteste Datenbank der Welt MySQL: Eine Einführung in die beliebteste Datenbank der Welt Apr 12, 2025 am 12:18 AM

MySQL ist ein Open Source Relational Database Management -System, das hauptsächlich zum schnellen und zuverlässigen Speicher und Abrufen von Daten verwendet wird. Sein Arbeitsprinzip umfasst Kundenanfragen, Abfragebedingungen, Ausführung von Abfragen und Rückgabergebnissen. Beispiele für die Nutzung sind das Erstellen von Tabellen, das Einsetzen und Abfragen von Daten sowie erweiterte Funktionen wie Join -Operationen. Häufige Fehler umfassen SQL -Syntax, Datentypen und Berechtigungen sowie Optimierungsvorschläge umfassen die Verwendung von Indizes, optimierte Abfragen und die Partitionierung von Tabellen.

MySQL und SQL: Wesentliche Fähigkeiten für Entwickler MySQL und SQL: Wesentliche Fähigkeiten für Entwickler Apr 10, 2025 am 09:30 AM

MySQL und SQL sind wesentliche Fähigkeiten für Entwickler. 1.MYSQL ist ein Open -Source -Relational Database Management -System, und SQL ist die Standardsprache, die zum Verwalten und Betrieb von Datenbanken verwendet wird. 2.MYSQL unterstützt mehrere Speichermotoren durch effiziente Datenspeicher- und Abruffunktionen, und SQL vervollständigt komplexe Datenoperationen durch einfache Aussagen. 3. Beispiele für die Nutzung sind grundlegende Abfragen und fortgeschrittene Abfragen wie Filterung und Sortierung nach Zustand. 4. Häufige Fehler umfassen Syntaxfehler und Leistungsprobleme, die durch Überprüfung von SQL -Anweisungen und Verwendung von Erklärungsbefehlen optimiert werden können. 5. Leistungsoptimierungstechniken umfassen die Verwendung von Indizes, die Vermeidung vollständiger Tabellenscanning, Optimierung von Join -Operationen und Verbesserung der Code -Lesbarkeit.

So verwenden Sie ein einzelnes Gewinde -Redis So verwenden Sie ein einzelnes Gewinde -Redis Apr 10, 2025 pm 07:12 PM

Redis verwendet eine einzelne Gewindearchitektur, um hohe Leistung, Einfachheit und Konsistenz zu bieten. Es wird E/A-Multiplexing, Ereignisschleifen, nicht blockierende E/A und gemeinsame Speicher verwendet, um die Parallelität zu verbessern, jedoch mit Einschränkungen von Gleichzeitbeschränkungen, einem einzelnen Ausfallpunkt und ungeeigneter Schreib-intensiver Workloads.

So wiederherstellen Sie Daten nach dem Löschen von SQL Zeilen So wiederherstellen Sie Daten nach dem Löschen von SQL Zeilen Apr 09, 2025 pm 12:21 PM

Das Wiederherstellen von gelöschten Zeilen direkt aus der Datenbank ist normalerweise unmöglich, es sei denn, es gibt einen Backup- oder Transaktions -Rollback -Mechanismus. Schlüsselpunkt: Transaktionsrollback: Führen Sie einen Rollback aus, bevor die Transaktion Daten wiederherstellt. Sicherung: Regelmäßige Sicherung der Datenbank kann verwendet werden, um Daten schnell wiederherzustellen. Datenbank-Snapshot: Sie können eine schreibgeschützte Kopie der Datenbank erstellen und die Daten wiederherstellen, nachdem die Daten versehentlich gelöscht wurden. Verwenden Sie eine Löschanweisung mit Vorsicht: Überprüfen Sie die Bedingungen sorgfältig, um das Verhandlich von Daten zu vermeiden. Verwenden Sie die WHERE -Klausel: Geben Sie die zu löschenden Daten explizit an. Verwenden Sie die Testumgebung: Testen Sie, bevor Sie einen Löschvorgang ausführen.

See all articles