Basic mysql knowledge, mysql

Source: Internet
Author: User

Basic mysql knowledge, mysql
1. Why use the database:
(1) reducing storage data redundancy
(2) Higher Data Consistency
(3) storage data can be shared
(4) standards that can be followed by Databases
(5) easy to maintain data integrity
(6) Data Security
2. In the history of database development, many different data models have emerged, including hierarchical models, mesh models, relational models, and object models.
3. Basic concepts of relational databases: Relational Models regard the world as composed of entities and connections. Entities may be tangible or intangible, specific or abstract, with or without life.
Databases created using Relational models are called Relational databases ). A table is the core unit of a relational database and the place where data is stored.
For relational databases, there are three basic types of relationships between tables: one-to-one, one-to-many, and many-to-many.
4. Data Type:
(1) Integer Data Type
TINYINT: the data storage range is from 0 to 255. Each data type occupies 1 byte of storage space.
SMALLINT: the data storage range is-2 ^ 15 to 2 ^ 15-1. Each data type occupies two sub-sections of storage space.

INT: the data storage range is from-2 ^ 31 to 2 ^ 31-1. Each type of data occupies 4 bytes of storage space.

BIGINT: the data storage range is from-2 ^ 63 to 2 ^ 63-1. Each type of data occupies 8 bytes of storage space.

(2) floating point data type:
REAL: It can be accurate to 7th decimal places, and its range is-3.1-40E-38 to 3.40E + 38. Each data type occupies 4 bytes of storage space.
FLOAT: It can be precise to 15th decimal places. Each FLOAT data occupies 8 bytes of storage space.
DECIMAL: Provides the actual storage space required for decimals, such as decimal (), which indicates a 15-digit number, with an integer of 10 digits and a DECIMAL of 5 digits.
(3) string type:
CHAR: Specifies the length of data. The maximum length is 8 KB.
VARCHAR: variable-length data with a length of no more than 8 KB. This type has no initial length value. You must specify the length in the format of VARCHAR (X). X indicates the maximum number of characters allowed.
TEXT: ASCII data larger than 8 KB can be stored as text data.
(4) Date and Time data types:
DATETIME: used to store the combination of date and time.

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.