Some points to be aware of in MySQL

Source: Internet
Author: User
Tags string format

A few common commands:

Select Database (); #查看当前所在的数据库.

Select User (); #查看当前登录的用户

Knowledge points that may be missed:

In the InnoDB storage engine, you must have a primary key in a table, and when you do not specify a field as the primary key, InnoDB selects the first non-empty and unique field as the key.

Foreign keys are unique to the InnoDB storage engine, other search engines do not have this feature, in fact, the foreign key is a combination of Python.

CREATE TABLE Table 2 Select required fields from table 1; #拷贝表1结构 + record to table 2

CREATE TABLE Table 2 Select required fields from table 1 where 1=2; #只拷贝表1的结构到表2

How to determine the three relationships of a table:

First, stand at the angle of a table and consider whether the table's multiple record objects can correspond to an object to join the table, that is, whether it is a multi------> one; second, stand in the perspective of another table, whether multiple objects of the table correspond to an object of another table, that is, whether it is more than one. If the two-time many-to-one is established, then the relationship between the two tables is many-to-many.

According to the above two comparisons, if only one is established, it is a pair-to-many relationship.

If you stand on two tables and think about it, it is a one-to-one relationship that only one object of a table corresponds to an object of another table. (Potential user form-------> Enrolment form)

Fields that are set as the primary key will default to their own non-empty, unique constraints.

Two types of characters;

char (NUMERIC): fixed-length string format, the length of the character is 0-255 (a character is also a char, using UTF-8 encoding when the use of three bytes), for the length of the stored characters is less than the value specified by char, the characters that are stored are populated, To the numeric length specified by char. Although space is wasted, access is highly efficient.

varchar (numeric): A variable length string format, that is, how long the character is deposited into the actual number of characters, but it is important to note here, for this kind of indefinite character format, you need a character to explain the length of the characters deposited, the last deposit format is: Data length description character + Actual character data. While this format saves space, access is inefficient and is recommended for less.

Some points to be aware of in MySQL

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.