찾다
데이터 베이스MySQL 튜토리얼绑定变量窥视是否开启和直方图关系

绑定变量窥视是否开启和直方图关系

Jun 07, 2016 pm 04:39 PM
관계변하기 쉬운켜다히스토그램제본

如果有直方图信息,而且绑定变量窥视也开启了,这里我们很好理解,在oracle 9i和oracle 10g时,sql第一次执行会将绑定变量的值带入到sql中,然后根据直方图等统计信息来评估合理的执行计划,在同样的sql下次执行时,会直接使用之前的执行计划,这个也就是我

如果有直方图信息,而且绑定变量窥视也开启了,这里我们很好理解,在oracle 9i和oracle 10g时,sql第一次执行会将绑定变量的值带入到sql中,然后根据直方图等统计信息来评估合理的执行计划,在同样的sql下次执行时,会直接使用之前的执行计划,这个也就是我们经常所接触的绑定变量窥视。

1) 开启了绑定变量窥视,收集该列的直方图:
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

SQL> alter system set "_optim_peek_user_binds"=true;

System altered.

SQL> create table t002 as select * from dba_objects;

Table created.

SQL> update t002 set object_id=100 where rownum
49999 rows updated.

SQL> commit;

Commit complete.

SQL> execute dbms_stats.gather_table_stats(ownname=>'XIAOYU',tabname=>'T002',met
hod_opt=>'for all columns size 254');

PL/SQL procedure successfully completed.

SQL> select num_rows,blocks from user_tables where table_name='T002';

  NUM_ROWS     BLOCKS
---------- ----------
     50328        712

SQL> select num_distinct,density,num_nulls from user_tab_columns where table_nam
e='T002' and column_name='OBJECT_ID';

NUM_DISTINCT    DENSITY  NUM_NULLS
------------ ---------- ----------
          29 9.8243E-06          0

SQL> variable x number;
SQL> exec : x:=100;

PL/SQL procedure successfully completed.

SQL> select count(*) from t002 where object_id=:x;

  COUNT(*)
----------
     49999
SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  4yqsqnawx85ty, child number 0
-------------------------------------
select count(*) from t002 where object_id=:x

Plan hash value: 3014849763

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   158 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |     4 |            |          |
|*  2 |   TABLE ACCESS FULL| T002 | 50065 |   195K|   158   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T002@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("OBJECT_ID"=:X)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT(*)[22]

30 rows selected.

SQL> exec : x:=1;

PL/SQL procedure successfully completed.

SQL> select count(*) from t002 where object_id=:x;

  COUNT(*)
----------
         0

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  4yqsqnawx85ty, child number 0
-------------------------------------
select count(*) from t002 where object_id=:x

Plan hash value: 3014849763

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   158 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |     4 |            |          |
|*  2 |   TABLE ACCESS FULL| T002 | 50065 |   195K|   158   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T002@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("OBJECT_ID"=:X)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT(*)[22]

30 rows selected.

这里比较好理解,由于开启了绑定变量窥视,然后该列又有直方图信息,所以第一次执行时会把具体值带入,然后根据具体值的直方图信息来评估rows,这里的通过谓词过滤后估算返回的rows是50065,关于有直方图的情况下估算rows的方式,非常复杂,小鱼自己也没有过多的深究,后面有机会整理相应的文章来分享。

2)如果开启了绑定变量窥视,但是没有收集直方图:
SQL> alter system set "_optim_peek_user_binds"=true;

System altered.

SQL> execute dbms_stats.gather_table_stats(ownname=>'XIAOYU',tabname=>'T002',met
hod_opt=>'for all columns size 1');

PL/SQL procedure successfully completed.

SQL>variable y number;
SQL>exec : y:=100

PL/SQL procedure successfully completed

SQL> select count(*) from t002 where object_id=:y;

  COUNT(*)
----------
     49999

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------

SQL_ID  86ngbvm962n14, child number 0
-------------------------------------
select count(*) from t002 where object_id=:y

Plan hash value: 3014849763

--------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   158 (100)|
|   1 |  SORT AGGREGATE    |      |     1 |     4 |            |
|*  2 |   TABLE ACCESS FULL| T002 |  1290 |  5160 |   158   (1)| 00:00:02
--------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T002@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("OBJECT_ID"=:Y)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT(*)[22]

30 rows selected.

这里我们来算算这个rows 1290是如何估算出来的

这里介绍最简单的如何计算rows,selectivity、density的公式:(下列计算公式在该列没有直方图前提下)

小鱼之前介绍cbo优化器的基本知识里面提过一个selectivity可选择率这个概念

可选择率selectivity=释放指定谓词条件返回结果集的记录数/未施加任何谓词条件的原始结果集的记录数,可选择率越大,那么cbo估算返回的rows也越大。

那么集的势rows=selectivity*未施加任何谓词条件的原始结果集的记录数

那么这个可选择率selectivity如何计算了,在列的统计信息中num_nulls为0时,selectivity=1/num_distinct

SQL> select num_distinct,num_nulls,density,num_buckets from dba_tab_columns wher
e table_name='T002' and column_name='OBJECT_ID';

NUM_DISTINCT  NUM_NULLS    DENSITY NUM_BUCKETS
------------ ---------- ---------- -----------
          39          0 .025641026           1

SQL> select num_rows from user_tables where table_name='T002';

  NUM_ROWS
----------
     50328

SQL> select 1/39 from dual;

      1/39
----------
.025641026

SQL> select 50328*1/39 from dual;

50328*1/39
----------
1290.46154

这里我们通过统计信息发现计算而来的1290跟执行计划的rows 1290完全一致

列没有直方图,而且num_nulls为0时:
Selectivity_without_null=(1/num_distinct),也就是列的统计信息中num_nulls为0时,列的选择率是1/num_distinct,此时density也是等于1/num_distinct

列没有直方图,但是num_nulls又不为0时:
selectivity_with_null=(1/num_distinct)*(num_rows-num_nulls)/(num_rows),而density还是等于1/num_distinct

对于第一点num_nulls为0,列没有直方图,selectivity选择率和density上面已经进行了验证,下面稍微扩展点,来验证下num_nulls不为0,没有直方图时,可选择率selectivity、rows和density关系

SQL> update t002 set object_id=null where rownum SQL> commit;
SQL> execute dbms_stats.gather_table_stats(ownname=>'XIAOYU',tabname=>'T002',method_opt=>'for all columns size 1');

SQL> select NUM_ROWS, --表中的记录数
  2  BLOCKS, --表中数据所占的数据块数
  3  EMPTY_BLOCKS, --表中的空块数
  4  AVG_SPACE, --数据块中平均的使用空间
  5  CHAIN_CNT, --表中行连接和行迁移的数量
  6  AVG_ROW_LEN --每条记录的平均长度
  7  from dba_tables
  8  where owner=&owner and table_name=&tabname;
Enter value for owner: 'XIAOYU'
Enter value for tabname: 'T002'
old   8: where owner=&owner and table_name=&tabname
new   8: where owner='XIAOYU' and table_name='T002'

  NUM_ROWS     BLOCKS EMPTY_BLOCKS  AVG_SPACE  CHAIN_CNT AVG_ROW_LEN
---------- ---------- ------------ ---------- ---------- -----------
     50328        712            0          0          0          91

SQL> SELECT column_name,
  2         num_distinct,
  3         num_nulls,
  4         density,
  5         num_buckets,
  6         low_value,
  7         high_value
  8    FROM dba_tab_col_statistics
  9   WHERE     owner = &owner
 10         AND table_name = &tabname
 11         AND column_name IN (&col1);
Enter value for owner: 'XIAOYU'
old   9:  WHERE     owner = &owner
new   9:  WHERE     owner = 'XIAOYU'
Enter value for tabname: 'T002'
old  10:        AND table_name = &tabname
new  10:        AND table_name = 'T002'
Enter value for col1: 'OBJECT_ID'
old  11:        AND column_name IN (&col1)
new  11:        AND column_name IN ('OBJECT_ID')

COLUMN_NAME              NUM_DISTINCT  NUM_NULLS    DENSITY    NUM_BUCKETS LOW_VALUE                      HIGH_VALUE
------------------------------ ------------ ---------- ---------- ----------- --
---------------------------- ------------------------------
OBJECT_ID                         44           943            .022727273         1 C2
02                           C3064A3F

SQL> select count(*) from t002 where object_Id=100;

  COUNT(*)
----------
     49000

SQL> select * from table(dbms_xplan.display_cursor(null,null));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  3yaw02xfsf7c8, child number 0
-------------------------------------
select count(*) from t002 where object_Id=100

Plan hash value: 3014849763

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   158 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |     3 |            |          |
|*  2 |   TABLE ACCESS FULL| T002 |  1122 |  3366 |   158   (1)| 00:00:02 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("OBJECT_ID"=100)


19 rows selected.

来算算选择率selectivity_with_null=(1/num_distinct)*(num_rows-num_nulls)/(num_rows)
 
SQL> select (50328-943)/50328*1/44 from dual;

(50328-943)/50328*1/44
----------------------
             .02230143

算算density=1/num_distinct也跟dba_tab_columns中值一样

SQL> select 1/44 from dual;

      1/44
----------
.022727273

根据选择率selectivity_with_null跟执行计划的预估的rows也是相符的,这个地方要注意rows是严格根据num_rows*selectivity的,而不是num_rows*density,因为在没直方图时density计算方式始终是1/num_distinct

SQL> select 0.02230143* 50328 from dual;

0.02230143*50328
----------------
      1122.38637

细心点我们发觉上面计算selectivity的方式可以直接简化为:
(1/num_distinct)*(num_rows-num_nulls)/num_rows,如果num_null为0, 此时(1/num_distinct)*(num_rows-num_nulls)/num_rows就直接等于1/num_distinct

3)关闭绑定变量窥视,也不收集直方图:
SQL> create table t003 as select * from dba_objects;

Table created.

SQL> alter system set "_optim_peek_user_binds"=false;

System altered.

SQL> update t003 set object_id=10000 where object_id
48524 rows updated.

SQL> commit;

Commit complete.

SQL> execute dbms_stats.gather_table_stats(ownname=>'SYS',tabname=>'T003',method
_opt=>'for all columns size 1');

PL/SQL procedure successfully completed.

SQL> select num_rows from user_tables where table_name='T003';

  NUM_ROWS
----------
     50325

SQL> select num_distinct,density,num_nulls from user_tab_columns where table_nam
e='T003' and column_name='OBJECT_ID';

NUM_DISTINCT    DENSITY  NUM_NULLS
------------ ---------- ----------
         184 .005434783          0

SQL> variable a number;
SQL> exec : a:=10000;

PL/SQL procedure successfully completed.

SQL> select count(object_name) from t003 where object_id=:a;

COUNT(OBJECT_NAME)
------------------
             48524

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  dq92pjhyfrg1n, child number 0
-------------------------------------
select count(object_name) from t003 where object_id=:a

Plan hash value: 3872854764

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   154 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    29 |            |          |
|*  2 |   TABLE ACCESS FULL| T003 |   274 |  7946 |   154   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T003@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("OBJECT_ID"=:A)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT("OBJECT_NAME")[22]
   2 - "OBJECT_NAME"[VARCHAR2,128]

31 rows selected.

SQL> exec : a:=10;

PL/SQL procedure successfully completed.

SQL> select count(object_name) from t003 where object_id=:a;

COUNT(OBJECT_NAME)
------------------
                 0

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  dq92pjhyfrg1n, child number 0
-------------------------------------
select count(object_name) from t003 where object_id=:a

Plan hash value: 3872854764

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   154 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    29 |            |          |
|*  2 |   TABLE ACCESS FULL| T003 |   274 |  7946 |   154   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T003@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("OBJECT_ID"=:A)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT("OBJECT_NAME")[22]
   2 - "OBJECT_NAME"[VARCHAR2,128]

31 rows selected.

关闭绑定变量,没有直方图时:
可选择率selectivity=1/num_distinct*(num_rows-num_nulls)/num_rows

SQL> select 50325*1/184 from dual;

50325*1/184
-----------
 273.505435

SQL> select 50325*0.005434783 from dual;

50325*0.005434783
-----------------
       273.505454

特别注意点:
而且我们查看v$sql时发现,关闭绑定变量窥视并不是不共享sql,而是说sql第一次执行时不带入具体值,这个如果大家没有测试过可能会想当然的以为是关闭绑定变量窥视是不共享绑定的sql语句,其实绑定变量窥视真正含义是sql第一次执行时带入绑定具体值,而如果关闭了绑定变量窥视,则不会带入具体值,那么由于不带入具体值,直方图也不会影响selectivity计算
 
SQL> select child_number,sql_id,sql_text from v$sql where sql_text like 'select
count(object_name) from t003 where object_id=:a%';

CHILD_NUMBER SQL_ID
------------ -------------
SQL_TEXT
--------------------------------------------------------------------------------
------------------------------------------------------------
           0 dq92pjhyfrg1n
select count(object_name) from t003 where object_id=:a

4)关闭绑定变量窥视,收集直方图:
SQL> alter system set "_optim_peek_user_binds"=false;

System altered.

SQL> execute dbms_stats.gather_table_stats(ownname=>'SYS',tabname=>'T003',method
_opt=>'for all columns size 254');

PL/SQL procedure successfully completed.

SQL> select num_rows from user_tables where table_name='T003';

  NUM_ROWS
----------
     50325

SQL> select num_distinct,density,num_nulls from user_tab_columns where table_nam
e='T003' and column_name='OBJECT_ID';

NUM_DISTINCT    DENSITY  NUM_NULLS
------------ ---------- ----------
         197 .000010034          0

SQL> variable b number;
SQL> exec : b:=10000;

PL/SQL procedure successfully completed.

SQL> select count(object_name) from t003 where object_id=:b;

COUNT(OBJECT_NAME)
------------------
             48524

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  9qunh3ms4kjzw, child number 0
-------------------------------------
select count(object_name) from t003 where object_id=:b

Plan hash value: 3872854764

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   154 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    29 |            |          |
|*  2 |   TABLE ACCESS FULL| T003 |   255 |  7395 |   154   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T003@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("OBJECT_ID"=:B)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT("OBJECT_NAME")[22]
   2 - "OBJECT_NAME"[VARCHAR2,128]

31 rows selected.

SQL> exec : b:=10;

PL/SQL procedure successfully completed.

SQL> select count(object_name) from t003 where object_id=:b;

COUNT(OBJECT_NAME)
------------------
                 0

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
------------------------------------------------------------
SQL_ID  9qunh3ms4kjzw, child number 0
-------------------------------------
select count(object_name) from t003 where object_id=:b

Plan hash value: 3872854764

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |   154 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    29 |            |          |
|*  2 |   TABLE ACCESS FULL| T003 |   255 |  7395 |   154   (1)| 00:00:02 |
---------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   2 - SEL$1 / T003@SEL$1

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("OBJECT_ID"=:B)

Column Projection Information (identified by operation id):
-----------------------------------------------------------

   1 - (#keys=0) COUNT("OBJECT_NAME")[22]
   2 - "OBJECT_NAME"[VARCHAR2,128]

31 rows selected.

如果有直方图,但是关闭绑定变量窥视,由于无法把绑定变量的值带入sql语句中,此时selectivity计算方式还是1/num_distinct*(num_rows-num_nulls)/num_rows
SQL> select 50325*1/197 from dual;

50325*1/197
-----------
 255.456853

在关闭绑定变量窥视后,sql语句还是会软解析,只是绑定变量的sql语句第一次执行时无法带入到sql语句中,selectivity计算无法应用到直方图信息,所以此时有无直方图对于这类绑定变量的sql语句没有影响。

关于有直方图时,字段的可选择、density等如何计算,小鱼后续会整理文档来分享。

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
MySQL 성능을 모니터링하는 데 사용할 수있는 몇 가지 도구는 무엇입니까?MySQL 성능을 모니터링하는 데 사용할 수있는 몇 가지 도구는 무엇입니까?Apr 23, 2025 am 12:21 AM

MySQL 성능을 효과적으로 모니터링하는 방법은 무엇입니까? Mysqladmin, Showglobalstatus, Perconamonitoring and Management (PMM) 및 MySQL Enterprisemonitor와 같은 도구를 사용하십시오. 1. MySQLADMIN을 사용하여 연결 수를보십시오. 2. showglobalstatus를 사용하여 쿼리 번호를보십시오. 3.pmm은 자세한 성능 데이터 및 그래픽 인터페이스를 제공합니다. 4. MySQLENTERPRISOMITOR는 풍부한 모니터링 기능 및 경보 메커니즘을 제공합니다.

MySQL은 SQL Server와 어떻게 다릅니 까?MySQL은 SQL Server와 어떻게 다릅니 까?Apr 23, 2025 am 12:20 AM

MySQL과 SqlServer의 차이점은 1) MySQL은 오픈 소스이며 웹 및 임베디드 시스템에 적합합니다. 2) SQLServer는 Microsoft의 상용 제품이며 엔터프라이즈 수준 애플리케이션에 적합합니다. 스토리지 엔진의 두 가지, 성능 최적화 및 응용 시나리오에는 상당한 차이가 있습니다. 선택할 때는 프로젝트 규모와 향후 확장 성을 고려해야합니다.

MySQL을 통해 어떤 시나리오에서 SQL Server를 선택할 수 있습니까?MySQL을 통해 어떤 시나리오에서 SQL Server를 선택할 수 있습니까?Apr 23, 2025 am 12:20 AM

고 가용성, 고급 보안 및 우수한 통합이 필요한 엔터프라이즈 수준의 응용 프로그램 시나리오에서는 MySQL 대신 SQLServer를 선택해야합니다. 1) SQLServer는 고 가용성 및 고급 보안과 같은 엔터프라이즈 수준의 기능을 제공합니다. 2) VisualStudio 및 Powerbi와 같은 Microsoft Ecosystems와 밀접하게 통합되어 있습니다. 3) SQLSERVER는 성능 최적화에서 우수한 성능을 발휘하며 메모리 최적화 된 테이블 및 열 스토리지 인덱스를 지원합니다.

MySQL은 문자 세트 및 콜라이트를 어떻게 처리합니까?MySQL은 문자 세트 및 콜라이트를 어떻게 처리합니까?Apr 23, 2025 am 12:19 AM

mysqlmanagesCharactersetsandcollationsUtf-8AsthedEfault, confonfigurationAtdatabase, 테이블 및 columnlevels, andcolumnlevels, andcolumnlevels, andcolumnlevels, 1) setDefaultCharactersetandcollationforadatabase.2) secigurecharactersetandcollation

MySQL의 트리거는 무엇입니까?MySQL의 트리거는 무엇입니까?Apr 23, 2025 am 12:11 AM

MySQL 트리거는 특정 데이터 작업이 수행 될 때 일련의 작업을 수행하는 데 사용되는 테이블과 관련된 자동 실행 된 저장 프로 시저입니다. 1) 트리거 정의 및 기능 : 데이터 검증, 로깅 등에 사용됩니다. 2) 작업 원칙 : 전후에 나누어지고 행 수준 트리거링을 지원합니다. 3) 사용의 예 : 급여 변경을 기록하거나 재고를 업데이트하는 데 사용할 수 있습니다. 4) 디버깅 기술 : ShowTriggers 및 ShowCreateTrigger 명령을 사용하십시오. 5) 성능 최적화 : 복잡한 작업을 피하고 인덱스 사용 및 거래 관리.

MySQL에서 사용자 계정을 어떻게 작성하고 관리합니까?MySQL에서 사용자 계정을 어떻게 작성하고 관리합니까?Apr 22, 2025 pm 06:05 PM

MySQL에서 사용자 계정을 작성하고 관리하는 단계는 다음과 같습니다. 1. 사용자 만들기 : CreateUser'Newuser '@'localhost'Identifiedby'Password '; 2. 권한 할당 : GrantSelect 사용, 삽입, UpdateOnmyDatabase.to'newuser'@'localhost '; 3. 권한 오류 수정 : Revokeallprivilegesonmydatabase.from'Newuser'@'localhost '; 그런 다음 권한을 재 할당합니다. 4. 최적화 권한 : showgra를 사용하십시오

MySQL은 Oracle과 어떻게 다릅니 까?MySQL은 Oracle과 어떻게 다릅니 까?Apr 22, 2025 pm 05:57 PM

MySQL은 빠른 개발 및 중소형 응용 프로그램에 적합한 반면 Oracle은 대기업 및 고 가용성 요구에 적합합니다. 1) MySQL은 오픈 소스이며 사용하기 쉬우 며 웹 응용 프로그램 및 중소 기업에 적합합니다. 2) Oracle은 강력하고 대기업 및 정부 기관에 적합합니다. 3) MySQL은 다양한 스토리지 엔진을 지원하며 Oracle은 풍부한 엔터프라이즈 수준의 기능을 제공합니다.

다른 관계형 데이터베이스와 비교하여 MySQL을 사용하는 단점은 무엇입니까?다른 관계형 데이터베이스와 비교하여 MySQL을 사용하는 단점은 무엇입니까?Apr 22, 2025 pm 05:49 PM

다른 관계형 데이터베이스와 비교하여 MySQL의 단점에는 다음이 포함됩니다. 1. 성능 문제 : 대규모 데이터를 처리 할 때 병목 현상을 만날 수 있으며 PostgreSQL은 복잡한 쿼리 및 빅 데이터 처리에서 더 잘 수행됩니다. 2. 확장 성 : 수평 스케일링 능력은 Google 스패너 및 Amazon Aurora만큼 좋지 않습니다. 3. 기능 제한 : 고급 기능에서 PostgreSQL 및 Oracle만큼 좋지 않으면 일부 기능에는 더 많은 사용자 정의 코드 및 유지 관리가 필요합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전