MySQL related issues

Source: Internet
Author: User

1. How to prevent SQL injection

    • Check the variable type, and if it is shaping, use the Intval method to convert to int
    • The string type uses the Addslashes function to filter special characters (it adds a backslash escape before the specified predefined characters, which are: Single quotation mark (') Double quotation mark (") backslash (\) NULL)
    • If you are using MySQL, use mysqli_real_escape_string to filter the characters, but it is not completely prevented,
    • In fact, binding variables using precompiled statements are the best way to prevent SQL injection , and the semantics of using precompiled SQL statements will not change.

https://www.zhihu.com/question/22953267

2, MySQL Those keywords can not use the index?

    • Not in,! =, <>
    • Like "%xxx"
    • column for function operations.
    • WHERE index=1 OR a=10
    • A String type field (such as a phone number) that has a numeric value stored, remember not to drop the value quotation marks when querying, otherwise it is not OK to use the field related index.

3. What is the type of MySQL index?

Primary key index, unique index, federated Index, normal index

4. What is the main purpose of vertical split table optimization?

Each update causes the table's query cache to be emptied. So, you can put this field in another table so that you don't have to keep reading the fixed field, because the query cache will help you add a lot of performance.

5, table horizontal split There are several options?

Splitting defects by time will cause the old data query frequency is low, the query pressure of the new table is big

Use hash distribution by user ID, disperse evenly, but need to re-hash when adding table

MySQL related issues

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.