Home Database Mysql Tutorial Backend.com MySQL database video tutorial resource recommendation

Backend.com MySQL database video tutorial resource recommendation

Sep 01, 2017 am 11:17 AM
mysql Tutorial database

"Backend.com MySQL Database Video Tutorial" introduces the concept of database, as well as some basic contents commonly used in databases, such as addition, deletion, modification, query, etc. It also has knowledge about database security, such as anti-injection, etc.

Backend.com MySQL database video tutorial resource recommendation

Course playback address: http://www.php.cn/course/427.html

The teacher’s teaching style:

The teacher’s lectures are simple, clear, layer-by-layer analysis, interlocking, rigorous argumentation, rigorous structure, and use the logical power of thinking to attract students’ attention Strength, use reason to control the classroom teaching process. By listening to the teacher's lectures, students not only learn knowledge, but also receive thinking training, and are also influenced and influenced by the teacher's rigorous academic attitude

The more difficult point in this video is the definition and selection of data types :

1. Numeric types:

Mysql supports all numerical types in standard SQL, including strict data types (INTEGER, SMALLINT, DECIMAL, NUMBERIC), and approximate numerical data Type (FLOAT, REAL, DOUBLE PRESISION), and expand on this basis. After expansion, three integers with different lengths, TINYINT, MEDIUMINT, and BIGINT, were added, and a BIT type was added to store bit data.

INT type:

The 5 main integer types supported in MySQL are TINYINT, SMALLINT, MEDIUMINT, INT and BIGINT. These types are largely identical, only the size of the values ​​they store differ.

MySQL extends the SQL standard in the form of an optional display width indicator so that when a value is retrieved from the database, the value can be lengthened to a specified length. For example, specifying that a field is of type INT(6) ensures that values ​​containing fewer than six digits are automatically padded with spaces when retrieved from the database. Note that using a width indicator does not affect the size of the field or the range of values ​​it can store. In case we need to store a number outside the allowed range in a field, MySQL will truncate it according to the end of the allowed range closest to it before storing it. Another special thing is that MySQL will automatically change the illegal value to 0 before inserting it into the table.

The UNSIGNED modifier specifies that the field only holds positive values. Because there is no need to save the positive and negative signs of the numbers, one "bit" of space can be saved during storage. This increases the range of values ​​that this field can store. The ZEROFILL modifier specifies that 0 (not spaces) can be used to complement the output value. Use this modifier to prevent the MySQL database from storing negative values.

FLOAT, DOUBLE, and DECIMAL types:

The three floating-point types supported by MySQL are the FLOAT, DOUBLE, and DECIMAL types. The FLOAT numeric type is used to represent single-precision floating-point values, while the DOUBLE numeric type is used to represent double-precision floating-point values. Like integers, these types take additional parameters: a display width indicator and a decimal point indicator. For example, the statement FLOAT(7,3) specifies that the displayed value will not exceed 7 digits, with 3 digits after the decimal point.

For a value with more digits after the decimal point than the allowed range, MySQL will automatically round it to the nearest value and then insert it. The DECIMAL data type is used in calculations that require very high precision. This type allows the precision and counting method of the numerical value to be specified as selection parameters. The precision here refers to the total number of significant digits saved for the value, while the counting method indicates the number of digits after the decimal point. For example, the statement DECIMAL(7,3) specifies that the stored value will not exceed 7 digits and will not exceed 3 digits after the decimal point.

Omitting the precision and counting method modifiers of the DECIMAL data type will cause the MySQL database to set the precision of all fields identified as this data type to 10 and the counting method to 0. The UNSIGNED and ZEROFILL modifiers can also be used with the FLOAT, DOUBLE, and DECIMAL data types. And the effect is the same as the INT data type.

1. CHAR and VARCHAR types:

The CHAR type is used for fixed-length strings and must be defined with a size modifier within parentheses. This size modifier ranges from 0-255. Values ​​larger than the specified length will be truncated, while values ​​smaller than the specified length will be padded with spaces.

The CHAR type can use the BINARY modifier. When used in comparison operations, this modifier causes CHAR to participate in the operation in binary form, rather than in the traditional case-sensitive manner.

A variant of the CHAR type is the VARCHAR type. It is a variable-length string type and must also have an indicator in the range 0-255. The difference between CHAR and VARCHGAR is the way the MYSQL database handles this indicator: CHAR treats this size as the size of the value, and pads it with spaces if the length is not insufficient. The VARCHAR type, on the other hand, treats this as the maximum value and only stores the value using the length actually required to store the string (plus one extra byte to store the length of the string itself). So VARCHAR types shorter than the indicator length will not be padded with spaces, but values ​​longer than the indicator will still be truncated. Because the VARCHAR type can dynamically change the length of the stored value based on the actual content, using the VARCHAR type when you are not sure how many characters a field requires can greatly save disk space and improve storage efficiency. The VARCHAR type is identical to the CHAR type when using the BINARY modifier.

2. TEXT and BLOB types:

When the field length requirement exceeds 255, MySQL provides two types: TEXT and BLOB. They all have different subtypes depending on the size of the stored data. These large data are used to store text blocks or binary data types such as images and sound files. There are differences in classification and comparison between TEXT and BLOB types. The BLOB type is case-sensitive, while TEXT is not case-sensitive. Size modifiers are not used on various BLOB and TEXT subtypes. Values ​​larger than the maximum range supported by the specified type will be automatically truncated.

3. Date and time types:

When dealing with date and time type values, MySQL comes with 5 different data types to choose from. They can be divided into simple date and time types, and mixed date and time types. Depending on the required precision, subtypes can be used within each subtype, and MySQL has built-in functionality to convert diverse input formats into a standard format.

1. DATE, TIME and TEAR types:

MySQL uses the DATE and TEAR types to store simple date values, and the TIME type to store time values. These types can be described as strings or sequences of integers without delimiters. If described as strings, values ​​of type DATE should be separated by hyphens as delimiters, and values ​​of type TIME should be separated by colons as delimiters.

It should be noted that a TIME type value without a colon separator will be understood by MySQL as a duration, not a timestamp.

MySQL also interprets to the maximum extent the value of two digits in the year of a date, or two digits entered for the TEAR type in an SQL statement. Because all TEAR type values ​​must be stored with 4 numbers. MySQL attempts to convert a 2-digit year to a 4-digit value. Converts values ​​in the range 00-69 to the range 2000-2069. Converts values ​​in the range 70-99 to 1970-1979. If the value automatically converted by MySQL does not meet our needs, enter a 4-digit year.

2. DATEYIME and TIMESTAMP types:

In addition to date and time data types, MySQL also supports two mixed types, DATEYIME and TIMESTAMP. They can store date and time as a single value. Both types are commonly used to automatically store timestamps containing the current date and time, and can work well in applications that need to perform a large number of database transactions and need to establish an audit trail for debugging and review purposes. If we do not explicitly assign a value to a field of TIMESTAMP type, or it is assigned a null value. MySQL automatically populates it with the system's current date and time.

3. Composite type:

MySQL also supports two composite data types, ENUM and SET, which extend the SQL specification. Although these types are technically string types, they can be treated as different data types. An ENUM type allows only one value to be obtained from a collection; a SET type allows any number of values ​​to be obtained from a collection.

4. ENUM type:

The ENUM type only allows one value to be obtained in the set, which is somewhat similar to a single option. Easier to understand when dealing with mutually exclusive data, such as human gender. ENUM type fields can take a value from a collection or use a null value, otherwise input will cause MySQL to insert an empty string into the field. In addition, if the case of the inserted value does not match the case of the values ​​in the collection, MySQL will automatically use the case of the inserted value to convert it to a value consistent with the case of the collection.

The ENUM type can be stored as a number internally in the system, and is indexed starting from 1. An ENUM type can contain up to 65536 elements, one of which is reserved by MySQL to store error information. This error value is represented by index 0 or an empty string. MySQL considers the values ​​appearing in the ENUM type collection to be legal input, and any other input will fail. This shows that the location of the erroneous record can be easily found by searching for rows that contain an empty string or a corresponding numeric index of 0.

5. SET type:

The SET type is similar to, but not identical to, the ENUM type. The SET type can take any number of values ​​from a predefined collection. And like the ENUM type, any attempt to insert a non-predefined value in a SET type field will cause MySQL to insert an empty string. If you insert a record that contains both legal and illegal elements, MySQL will retain the legal elements and remove the illegal elements.

A SET type can contain up to 64 elements. In a SET element the value is stored as a discrete sequence of "bits" that represent its corresponding element. Bits are a simple and efficient way to create ordered collections of elements. And it also removes duplicate elements, so it is impossible to contain two identical elements in a SET type. To find illegal records from a SET type field simply look for rows that contain an empty string or a binary value of 0.

By having a general understanding of the purpose, physical storage, representation range, etc. of each data type. In this way, when facing specific applications, we can choose the appropriate data type according to the corresponding characteristics, so that we can strive to achieve higher database performance with smaller storage costs on the basis of satisfying the application.

The above is the detailed content of Backend.com MySQL database video tutorial resource recommendation. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

How to create navicat premium How to create navicat premium Apr 09, 2025 am 07:09 AM

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

How to create a new connection to mysql in navicat How to create a new connection to mysql in navicat Apr 09, 2025 am 07:21 AM

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

How to recover data after SQL deletes rows How to recover data after SQL deletes rows Apr 09, 2025 pm 12:21 PM

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

How to use single threaded redis How to use single threaded redis Apr 10, 2025 pm 07:12 PM

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

See all articles