PHP mobile internet development notes (8)-MySQL database basic review [2] _ MySQL

Source: Internet
Author: User
PHP mobile internet development notes (8)-MySQL database basic review [2] bitsCN.com

I. Data Tables

To ensure data integrity and consistency, you must specify the field name, field type, and field attribute when creating a table. constraints, indexes, and ), primary key and foregin key.

Constraints:

Not null non-empty constraint

Unique uniqueness constraint

Primary key constraint

Foreign key constraint of foreign key

Check constraints

Auto_increment: automatically identifies a column (the value is automatically increased by 1)

Create a table:

Modify table:

Modify the table structure, such as modifying the column type, adding new fields, deleting original fields, and changing the table name.

Alter % 20 table % 20 user % 20 modify/add/drop/change/rename

Delete table:

Add data (add one or more data records at a time)

Query:

Modify table data:

Delete table records:

When the field in the table is too long: writing is inconvenient. we can use as to alias the field:

Remove duplicate queries and use distinct

The query value is in a certain range: select * from user where age between... and ..

Select * from user where name in ('"lixq", "lxq ");

Fuzzy query:

%: 0 to multiple characters

_: Represents any character

II. indexing

In database development, indexes can improve query optimization, ensure data uniqueness, and optimize search for a large number of text in any full-text index field. index classification: primary key index (primary key), unique index (unique), General index, full text index (fulltext );

III. database table types and storage locations

Mysql supports multiple data table types, such as MYISAM, InnoDB, and MEMORY.

View the storage engines supported by the current database

Generally, data tables are stored in the data file under the mysql installation directory.

IV. default character set of data tables

In a mysql database, you can set a different character set for the database, data table, or even each data column. If no character set is specified when you create a database using the create table command, it is determined by the character-set-server option in the mysql configuration file.

Modify the my. ini file in the directory

default-character-set=utf8character-set-server=utf8

If a set names gbk is added to windows to display Chinese characters, the display will be normal.

BitsCN.com

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.