Initial MySQL

1. Common sql syntax:

. A data definition language DDL (Data Definition Language): an object inside the database to create, modify, or delete operation; and DML difference is DML statements only data for a table, which relates to the table meta information; the DDL major DBA for ( database administrators)

 

b Data Manipulation Language DML (Data Manipulation Language):. CURD data in the database for CRUD, for developers 

 

. C data control statement DCL (Data Control Language): rights management system for an object, DBA facing

 

 

2. things (Transaction)

  Indivisible series of database operations that either the overall success or failure of the whole. Things to commit or rollback statement ends, commit represents the end of a successful execution of things, rollback denote something failed.

 

3. MySQL Performance Tuning

    Performance optimization proposition itself is larger, the need for a deeper understanding of the underlying principles of database storage principle, the implementation process, engines, etc., not to discuss in depth here.

    Solutions always the same: locate the problem ---> Finding solutions. Can help locate the root cause in conjunction with MySQL logs generated positioning means to implement plans.

4. Index

  After the reference index dictionary, create an index reading of data can improve efficiency, but will also reduce the efficiency of writing data; simple to understand and easier to find data based on the index, while the index needs to write data, write data will increase the burden.

Creating an index can refer to the following:

. A search index columns: create an index for the condition where the columns;

. B Use unique indexes: try to create an index on discrete data columns to help narrow your search; if not recommended to create indexes for the gender column because this index can only elect half of the deleted data;

. C using a short index (prefix index): the length of the index may be specified char (20), both good distinction can reduce the burden of data in the database when creating an index on columns char (200) of; create index cityname on city ( city ​​(10)); drop idex idex_name on tablename;

d. 不要过度索引:索引并不是越多越好,太多无用或不适合的索引会导致读写效率下降;Mysql在生成执行计划时需要考虑各个索引,花费时间;

e. InnoDB表尽量自己指定主键(每行唯一),InnoDB表的普通索引会保存主键的键值,选择较短的数据类型做主键可以有效减少索引的磁盘占用,提高索引的缓存效果。

 

5. SQL注入

    ​应用与数据库交互通过接口进行,数据库自身是无法分辨传入的SQL是合法的还是不合法的,如果传入的SQL语句被恶意用户控制或者篡改,将导致数据库以当前调用者的身份执行预期之外的命令并且返回结果,导致安全问题。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/beichenroot/p/10986417.html