MySQL General Registration Insert optimization.

Source: Internet
Author: User

The common practice is to:

The user is registered by phone number. The default is based on this mobile phone number to the user table query, see if there is this mobile phone number, there is a hint has been registered. Otherwise, perform a registration insert database operation. In fact, the normal registration process is two database operations (query, insert);

Optimization practices:

The phone number is set to a unique index. Perform the insert operation directly. This makes use of the MySQL error mechanism, if the number of the inserted phone with the database is duplicated, then call the MySQL method Mysql_errno () can see that the 1062;1062 represents the inserted mobile phone number database already exists. Insert failed. So we can know. Whether the user is already in the database. Only one insertion operation was done;

Explanation of common error codes attached to Mysql_errno section

1005: Failed to create TABLE 1006: Failed to create DATABASE 1007: Database already exists, failed to create DATABASE 1008: Database does not exist, delete database failed 1009: Failed to delete database file resulting in database deletion failure 1010: Unable to delete data directory resulting in deletion of database failed 1011: Failed to delete database file 1012: Cannot read record in system table 1016: Unable to open file 1020: Record has been modified by another user 1021: The hard disk has insufficient space, please increase the hard disk free space 1022: Duplicate keyword, change record failed 1023: Error 1024: Shutdown Read File Error 1025: Error 1026: Write file error 1032: Record does not exist 1036: The data table is read-only and cannot be modified 1037: system memory is low, restart the database or restart server 1038: Insufficient memory for sorting, Increase the sort buffer 1040: The maximum number of connections that have reached the database, increase the number of available connections to the database 1041: Insufficient system memory 1042: Invalid host name 1043: Invalid connection 1044: The current user does not have permission to access the database 1045: Cannot connect to the database. Username or password Error 1040: Maximum number of connections 1048: field cannot be empty 1049: Database does not exist 1050: Data table already exists 1051: Data table does not exist 1054: field does not exist 1065: Invalid SQL statement, SQL statement is empty 1081: Unable to establish socket connection 1114: Data table is full and cannot hold any record 1116: Open data table too many 1129: Database exception, restart database 1130: Failed to connect to database, no permission to connect to database 1133: Database user does not exist 1141: Current user does not have access to database 1142: Current user does not have access to data table 1143: Current user does not have access to field 1146 in Datasheet: Data table does not exist 1147: User access to data table not defined 1149:SQL statement syntax error 1158: Network error, read error occurred, Check network connectivity 1159: Network error, read timeout, check network connection status 1160: Network error, write error, check network connection status 1161: Network error, write timeout, check network connection Status 1062: Duplicate field value, inbound failed

MySQL General Registration Insert optimization.

Related Article

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.