Home Database Mysql Tutorial MySQL中SQL-TEXT、DATE和SET数据类型_MySQL

MySQL中SQL-TEXT、DATE和SET数据类型_MySQL

Jun 01, 2016 pm 02:00 PM
data sheet yes

MySQL 数据表的字段必须有定义一个数据类型。这有大约 25 种选择,大部分都是直接明了的,就不多费口舌了。但有几个有必要提一下。

TEXT

TEXT 不是一种数据类型,虽然可能有些书上是这么说的。它实际上应该是“ LONG VARCHAR ”或者“ MEDIUMTEXT ”。

DATE

DATE 数据类型的格式是 YYYY-MM-DD ,比如: 1999-12-08 。你可以很容易的用 date 函数来得到这种格式的当前系统时间:

date("Y-m-d")

并且,在 DATA 数据类型之间可以作减法,得到相差的时间天数:

$age = ($current_date - $birthdate);

SET

集合 SET 是一个有用的数据类型,它和枚举 ENUM 有点相似,只不过是 SET 能够保存多个值而 ENUM 只能保存一个值而已。而且, SET 类型最多只能够有 64 个预定的值,而 ENUM 类型却能够处理最多 65,535 个预定义的值。而如果需要有大于 64 个值的集合,该怎么办呢?这时就需要定义多个集合来一起解决这个问题了。

通配符

SQL 的同配符有两种:“ * ”和“ % ”。分别用在不同的情况下。例如:如果你想看到数据库的所有内容,可以像这样来查询:

SELECT * FROM dbname

WHERE USER_ID LIKE '%';

这儿,两个通配符都被用上了。他们表示相同的意思 ?? 都是用来匹配任何的字符串,但是他们用在不同的上下文中。“ * ”用来匹配字段名,而“ % ”用来匹配字段值。另外一个不容易引起注意的地方是“ % ”通配符需要和 LIKE 关键字一起使用。

还有一个通配符,就是下划线“ _ ”,它代表的意思和上面不同,是用来匹配任何单个的字符的

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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
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)

Data table compression technology in MySQL Data table compression technology in MySQL Jun 16, 2023 am 08:16 AM

MySQL is a common relational database that is a core component of many websites and applications. As the amount of data becomes larger and larger, how to optimize the performance of MySQL becomes particularly important. One of the key areas is the compression of data tables. In this article we will introduce the data table compression technology in MySQL. Compressed tables and non-compressed tables There are two types of data tables in MySQL: compressed tables and non-compressed tables. Uncompressed tables are MySQL's default table type, which use fixed-length row format to store data. This means data

mysql modify data table name mysql modify data table name Jun 20, 2023 pm 05:52 PM

MySQL modifies the data table: 1. First check all tables in the database, the code is: "SHOW TABLES;"; 2. Modify the table name, the code is: "ALTER TABLE old table name RENAME [TO] new table name;". 3. Check whether the table name is modified successfully. The code is: "SHOW TABLES;"

Data table DDL operation technology in MySQL Data table DDL operation technology in MySQL Jun 15, 2023 pm 07:55 PM

MySQL is a very popular open source relational database management system that supports complete DDL (data definition language) operations. DDL is a language used to define and manage various data objects in the database, including data tables, views, indexes, etc. It is very important for database administrators and developers to be proficient in DDL operation technology of data tables in MySQL. This article will introduce in detail the technology and methods of DDL operation of data tables in MySQL, and provide practical operation examples. 1. Create a data table. Creating a data table is in DDL.

How to calculate the average value of numeric columns in a data table using MySQL's AVG function How to calculate the average value of numeric columns in a data table using MySQL's AVG function Jul 24, 2023 pm 09:52 PM

Introduction to the method of using MySQL's AVG function to calculate the average value of numeric columns in a data table: MySQL is an open source relational database management system with a wealth of built-in functions to process and calculate data. Among them, the AVG function is a function used to calculate the average of a numeric column. This article will introduce how to use the AVG function to calculate the average value of numeric columns in a MySQL data table, and provide relevant code examples. 1. Create a sample data table First, we need to create a sample data table for demonstration. Suppose we have a file called

Data table reloading techniques in MySQL Data table reloading techniques in MySQL Jun 15, 2023 pm 11:28 PM

MySQL is an open source relational database management system. Its basic functions are excellent in database design, data storage and management. In MySQL, the data table is the most basic unit of data storage. In practical applications, data table reloading is a very common operating technique, which can help us improve the operating efficiency of the database and improve the stability of the system. This article will introduce this operation technique in detail from the concepts, principles and practical applications of data table overloading in MySQL. 1. What is data table overloading? Data table overloading is

What is NEAR Protocol Coin? What are the characteristics of NEAR Protocol coins? What is NEAR Protocol Coin? What are the characteristics of NEAR Protocol coins? Mar 04, 2024 pm 11:20 PM

NEARProtocol: A scalable, user-friendly blockchain platform NEARProtocol is a blockchain platform using sharding technology designed to address the challenges faced by blockchain technology in terms of scalability, user-friendliness, and security. It provides developers with an efficient and user-friendly platform that enables them to easily build and deploy decentralized applications (dApps). NEARProtocol is designed to lower the barriers to blockchain development while providing a high degree of efficiency and security. By adopting sharding technology, NEARProtocol can better handle large-scale transactions and provide users with faster transaction confirmation times. Overall, NEARProtocol is designed to provide

How to implement MySQL underlying optimization: horizontal and vertical splitting strategies for data tables How to implement MySQL underlying optimization: horizontal and vertical splitting strategies for data tables Nov 08, 2023 pm 06:57 PM

How to realize the underlying optimization of MySQL: horizontal and vertical partitioning strategies of data tables, which require specific code examples. Introduction: In large-scale application scenarios, MySQL databases often face the pressure of storing and querying massive data. In order to solve this problem, MySQL provides data table partitioning strategies, including horizontal partitioning (HorizontalPartitioning) and vertical partitioning (VerticalPartitioning). This article will introduce how to implement MySQL underlying optimization, focusing on

How to use the MAX function in MySQL to find the largest value in the data table How to use the MAX function in MySQL to find the largest value in the data table Jul 25, 2023 pm 09:49 PM

How to use the MAX function in MySQL to find the maximum value in the data table Introduction: In MySQL, we often need to perform various queries and analysis on the data table, including finding the maximum value in the data table. The maximum value in a data table can be easily found using the MAX function and is very useful when further processing the data. This article will introduce how to use the MAX function to find the largest value in the data table, and give corresponding code examples. 1. Introduction to the MAX function The MAX function is an aggregate function in MySQL. Use

See all articles