MySQL数据类型

MySQL数据类型

在本教程中,您将了解MySQL数据类型以及如何在MySQL中设计数据库时有效地使用它们。

数据库表包含具有特定数据类型(如数字或字符串)的多个列。 MySQL提供更多的数据类型,而不仅仅是数字或字符串。 MySQL中的每种数据类型都可以通过以下特征来确定:

  • 它用来表示数据值。
  • 占用的空间以及值是固定长度还是可变长度。
  • 数据类型的值可以被索引。
  • MySQL如何比较特定数据类型的值。
数据类型 指定值和范围
char String(0~255)
varchar String(0~255)
tinytext String(0~255)
text String(0~65536)
blob String(0~65536)
mediumtext String(0~16777215)
mediumblob String(0~16777215)
longblob String(0~4294967295)
longtext String(0~4294967295)
tinyint Integer(-128~127)
smallint Integer(-32768~32767)
mediumint Integer(-8388608~8388607)
int Integer(-214847668~214847667)
bigint Integer(-9223372036854775808~9223372036854775807)
float decimal(精确到23位小数)
double decimal(24~54位小数)
decimal double转储为字符串形式
date YYYY-MM-DD
datetime YYYY-MM-DD HH:MM:SS
timestamp YYYYMMDDHHMMSS
time HH:MM:SS
enum 选项值之一
set 选项值子集
boolean tinyint(1)

MySQL数值数据类型

在MySQL中,您可以找到所有SQL标准数字类型,包括精确数字数据类型和近似数字数据类型,包括整数,定点和浮点数。 此外,MySQL还具有用于存储位值的BIT数据类型。数字类型可以是有符号或无符号,但BIT类型除外。

下表显示了MySQL中数字类型的总结:

数字类型 描述
TINYINT 一个很小的整数
SMALLINT 一个小的整数
MEDIUMINT 一个中等大小的整数
INT 一个标准整数
BIGINT 一个大整数
DECIMAL 定点数
FLOAT 单精度浮点数
DOUBLE 双精度浮点数
BIT 一个字节字段

MySQL布尔数据类型

MySQL没有内置的 BOOLEANBOOL 数据类型。所以要表示布尔值,MySQL使用最小的整数类型,也就是TINYINT(1)。 换句话说,BOOLEANBOOLTINYINT(1)的同义词。

MySQL字符串数据类型

在MySQL中,字符串可以容纳从纯文本到二进制数据(如图像或文件)的任何内容。可以通过使用LIKE运算符,正则表达式和全文搜索,根据模式匹配来比较和搜索字符串。

下表显示了MySQL中的字符串数据类型:

字符串类型 描述
char 固定长度的非二进制(字符)字符串
varchar 可变长度的非二进制字符串
BINARY 一个固定长度的二进制字符串
VARBINARY 一个可变长度的二进制字符串
TINYBLOB 一个非常小的BLOB(二进制大对象)
BLOB 一个小的BLOB(二进制大对象)
MEDIUMBLOB 一个中等大小的BLOB(二进制大对象)
LONGBLOB 一个大的BLOB(二进制大对象)
TINYTEXT 一个非常小的非二进制字符串
TEXT 一个小的非二进制字符串
MEDIUMTEXT 一个中等大小的非二进制字符串
LONGTEXT 一个很大的非二进制字符串
ENUM 枚举; 每个列值可以被分配一个枚举成员
SET 集合; 每个列值可以分配零个或多个SET成员

MySQL日期和时间数据类型

MySQL提供日期和时间的类型以及日期和时间的组合。 此外,MySQL还支持时间戳数据类型,用于跟踪表的一行中的更改。如果只想存储没有日期和月份的年份数据,则可以使用YEAR数据类型。

下表说明了MySQL日期和时间数据类型:

字符串类型 描述
DATE YYYY-MM-DD格式的日期值
TIME hh:mm:ss格式的时间值
DATETIME YYYY-MM-DD hh:mm:ss格式的日期和时间值
TIMESTAMP YYYY-MM-DD hh:mm:ss格式的时间戳记值
YEAR YYYYYY格式的年值

MySQL空间数据类型

MySQL支持许多包含各种几何和地理值的空间数据类型,如下表所示:

字符串类型 描述
GEOMETRY 任何类型的空间值
POINT 一个点(一对X-Y坐标)
LINESTRING 曲线(一个或多个POINT值)
POLYGON 多边形
GEOMETRYCOLLECTION GEOMETRY值的集合
MULTILINESTRING LINESTRING值的集合
MULTIPOINT POINT值的集合
MULTIPOLYGON POLYGON值的集合

JSON数据类型

MySQL 5.7.8版本支持原生JSON数据类型,可以更有效地存储和管理JSON文档。 本机JSON数据类型提供JSON文档的自动验证和最佳存储格式。

在本教程中,您学习了各种MySQL数据类型,可帮助您确定在创建表时应使用哪些数据类型。

 

移动端:请扫描本页面底部(右侧)二维码并关注微信公众号,回复:”教程” 选择相关教程阅读

96 Responses

  1. Bpekew说道:

    lexapro pills lexapro uk purchase naltrexone online cheap

  2. Euwgmb说道:

    lasix brand order generic lasix 40mg order albuterol 2mg pills

  3. Vszkkb说道:

    strattera online buy zoloft price buy generic sertraline 50mg

  4. Qsztxq说道:

    ursodiol 300mg for sale brand ursodiol 300mg order zyrtec 5mg online

  5. Kvpwoo说道:

    buy azithromycin 250mg online prednisolone buy online buy generic gabapentin

  6. Hlpljg说道:

    benefits of taking hydrochloric acid mucosal healing supplements prescription medicine for flatulance

  7. Yizuec说道:

    oral deltasone 5mg prednisone 20mg cost amoxicillin 250mg over the counter

  8. Wteoqq说道:

    virtual birth control prescription delay ejaculation pills review walmart last longer pills

  9. Kvfkma说道:

    phenergan online order buy stromectol 12mg covid and ivermectin

  10. Qoiron说道:

    order cymbalta 40mg without prescription buy generic duloxetine buy generic modafinil over the counter

  11. Rrqpuc说道:

    lamisil toenail fungus success rate can you use abreva on genital herpes 4 deadly blood pressure medicines

  12. Dtjprr说道:

    cyproheptadine online buy order cyproheptadine 4mg sale buy ketoconazole medication

  13. Regsss说道:

    buy herpes drugs drugs to treat prediabete best diabetes drug without injection

  14. Rnzfva说道:

    buy medroxyprogesterone 10mg pill how to get praziquantel without a prescription buy hydrochlorothiazide 25mg for sale

  15. Ctyhrt说道:

    best supplements for quitting smoking oral medication to stop smoking list of opioid medications

  16. Cqdlig说道:

    letrozole 2.5 mg oral femara over the counter aripiprazole 30mg uk

  17. Xqnatq说道:

    virtual visit online physician insomnia get sleep medication online the strongest weight loss pill

  18. Ilsizi说道:

    buy cheap uroxatral alfuzosin 10mg generic best medicine in stomach pain

  19. Szherw说道:

    minomycin order online generic minocin ropinirole for sale

  20. knorp说道:

    Đến nay, OnCredit là đơn vị chuyên cung cấp dịch vụ tư vấn vay tiền, hỗ trợ hàng nghìn đơn đăng ký vay tiền nhanh online chuyển khoản 24 24 mỗi ngày. Rất nhiều khách hàng đã và đang đánh giá cao về chất lượng dịch vụ tại OnCredit. Đăng ký tư vấn vay tiền online ngay để trải nghiệm những ưu đãi chỉ có ở OnCredit! Cho vay phục vụ chính sách phát triển nông nghiệp nông thôn theo Nghị định 55 2015 NĐ-CP của Thủ tướng Chính phủ Hiện nay ở Việt Nam lãi suất không vượt quá 20% năm với sản phẩm vay ngắn hạn. Khi đăng ký vay tiền online bạn có thể nhận được ưu đãi vay tiền lãi suất 0%.
    http://www.lovedolles.com/bbs/board.php?bo_table=free&wr_id=363335
    Nhờ chương trình cho vay tiền online không cần gặp mặt chuyển tiền qua ngân hàng chỉ cần CMND, giờ đây khách hàng có thể dễ dàng huy động số tiền lên đến 15.000.000 VND trong 30 phút chỉ vài thao tác đăng ký website app vay tiền hỗ trợ nợ xấu uy tín trên Vay tiền trả góp theo tháng chỉ cần CMND là hình thức vay tín chấp, theo đó người vay sẽ không cần phải dùng các tài sản để đảm bảo, hay chứng minh thu nhập. Mà người vay chỉ cần sử dụng CMND của mình để tiến hành vay trả góp theo tháng.  Vay tiền mặt, kỳ hạn trả góp 3, 6, 9, 12 tháng. Giải ngân là một thật ngữ quen thuộc khi vay vốn ngân hàng. Bạn đã hiểu rõ giải ngân là gì và cách thủ tục giải ngân khi vay vốn ngân hàng chưa? Nếu nắm rõ quy trình và thủ tục thì hồ sơ vay vốn của bạn sẽ được ngân hàng tiến hành nhanh chóng, và bạn sẽ nhận tiền vay sớm. Trong bài viết sau, Timo sẽ cung cấp đầy đủ thông tin giải ngân là gì, các thủ tục giải ngân và những điều cần lưu ý khi giải ngân.

  21. Jjmsat说道:

    body acne causes in adults strongest acne over the counter buy oxcarbazepine 300mg for sale

  22. Eomxib说道:

    where to buy clonidine without a prescription buy meclizine pills spiriva sale

  23. Wxtgyc说道:

    rocaltrol 0.25 mg sale buy tricor generic buy fenofibrate tablets

  24. Ukdrxi说道:

    amoxicillin 250mg sale anastrozole 1 mg cost order biaxin 250mg pills

  25. Botaok说道:

    get assignments done online free slot machine games online gambling real money

  26. Wwecal说道:

    write me a essay cefixime 100mg pills cheap suprax 200mg

  27. Eyrwph说道:

    aspirin 75mg us online gambling sites casino free spin

  28. Wsgfwb说道:

    where can i buy terbinafine order terbinafine online casino online games

  29. Cwxiqi说道:

    trazodone online order desyrel for sale clindamycin oral

  30. Wcpqev说道:

    buy cefuroxime cheap purchase cefuroxime generic buy robaxin pill

  31. Wqdtro说道:

    buy tadalafil generic buy cambia tablets buy indocin 50mg generic

  32. Njoscd说道:

    buy nolvadex online buy nolvadex 20mg without prescription where can i buy symbicort

  33. Jslthn说道:

    buy tretinoin cream generic buy avanafil 200mg sale order avanafil pill

  34. Smbogk说道:

    brand clindamycin cheap erythromycin 500mg buy fildena generic

  35. Qgniqa说道:

    lamictal 50mg for sale minipress cost buy nemazole pills for sale

  36. Iquwvw说道:

    generic flagyl 400mg buy bactrim 960mg generic cephalexin online

  37. Msfsac说道:

    order sildenafil 50mg aurogra 100mg drug estrace for sale

  38. Xduzky说道:

    fluconazole price order fluconazole 100mg generic buy cipro tablets

  39. Jhiunw说道:

    buy dissertation online pay for term paper college essay writing help

  40. Gvuxdq说道:

    buy spironolactone 25mg aldactone 25mg usa buy propecia cheap

  41. Qgzhsj说道:

    order domperidone pill order generic tetracycline tetracycline for sale online

  42. Yghgti说道:

    tamsulosin 0.4mg pill zofran for sale buy simvastatin without a prescription

  43. Zmrjoq说道:

    buy buspirone 10mg pills cordarone 200mg drug amiodarone 200mg pills

  44. Uvlyyi说道:

    ranitidine cost order mobic sale celecoxib cost

  45. Ifmefl说道:

    buy zyloprim no prescription buy clobetasol no prescription cheap crestor 10mg

  46. Zpkjte说道:

    imitrex 50mg pill order levofloxacin 500mg online cheap buy cheap generic avodart

  47. Gauoom说道:

    order esomeprazole 40mg sale topamax 100mg price order topamax 200mg sale

  48. Dldqpo说道:

    buy astelin 10ml generic buy generic azelastine 10 ml avalide for sale online

  49. Diznpl说道:

    pepcid 20mg sale order tacrolimus 1mg prograf brand

  50. Ieujjj说道:

    xenical drug asacol 800mg drug buy diltiazem 180mg

  51. Vrispz说道:

    buy coumadin for sale paxil online cheap reglan

  52. Noioca说道:

    buy nortriptyline 25 mg sale order pamelor 25mg generic buy panadol 500mg pills

  53. Wxmshu说道:

    brand inderal motrin 600mg tablet plavix pill

  54. Dvcjnx说道:

    amaryl 1mg over the counter arcoxia 120mg usa arcoxia online buy

  55. Xbjhdo说道:

    buy generic fosamax for sale cost fosamax generic macrodantin 100 mg

  56. Ybzkfc说道:

    order baclofen generic buy toradol for sale ketorolac oral

  57. Kqmtsm说道:

    buy loratadine without a prescription claritin price priligy 30mg price

  58. Ymcavw说道:

    cost lioresal elavil sale how to buy ketorolac

  59. Dmobee说道:

    buy phenytoin without prescription order oxybutynin 2.5mg for sale order oxybutynin 5mg pills

  60. Ruhwnf说道:

    aceon 4mg usa purchase allegra generic allegra 180mg pill

  61. Duhtcp说道:

    vardenafil 10mg over the counter digoxin 250mg over the counter tizanidine over the counter

  62. wam说道:

    Today, classic slot machines are sometimes referred to as fruit slots, due to the commonly used fruit symbols which players need to try and match. Classic slots are enjoyed all around the world and are a staple both online and on land. For simplicity, familiarity and grind-ability, classic slots are simply the best! As far as slots go – Casino Classic is very well-equipped. However, we would like to see a bit more variety in the overall game selection, and some new live games would be a welcomed addition. – Easy to play with multiple slots features – Individual reel stop, Auto spin and classic slot lever At Bovada Casino, we know how to keep the good times rolling. With over 250 casino games to choose from and a ton of promotions that are sure to suit everyone’s style, Bovada Casino is the number one choice of thousands of players. It’s time to elevate your online gaming experience.
    https://juliusxwtq306306.bloggactif.com/1520286/400-poker-chip-set
    If you’re used to playing blackjack in a retail casino, then the live dealer version should be pretty familiar. For the most part, blackjack gameplay is the same. If playing with a real person sounds exciting, that’s because it truly is. You have come to the right place for all the latest information and news about live dealer casinos in Pennsylvania. The sections below will guide you to the best and brightest that Pennsylvania’s live dealer casinos have to offer. Live dealer casino games have taken the online casino experience to the next level. Unlike the standard online casino games that rely on random number generators to provide the outcome, live dealer games emulate the action from physical casinos. That said, the Blackjack variations include American Blackjack, European, Atlantic City, Vegas Strip, Classic Blackjack, etc. Interestingly, you can play the Multi-hand versions of these games. If the thrill of beating a croupier excites you, the operator has a live casino to quench your thirst. So, the games in this category include Infinite Blackjack, Party Blackjack, VIP, Diamond VIP, Diamond Blackjack, etc. While playing, you can enjoy fast payouts and stellar customer support to boot.

  63. Oyfwvz说道:

    buy methylprednisolone uk medrol 16mg for sale triamcinolone where to buy

  64. Jhadnn说道:

    purchase clomid for sale buy serophene where to buy azathioprine without a prescription

  65. Lbhprn说道:

    casino bonus hard rock casino online order generic levothroid

  66. Pujocu说道:

    order amantadine generic order avlosulfon dapsone 100 mg ca

  67. Ealtex说道:

    online slots for real money stromectol 6mg uk price of ivermectin liquid

  68. Anrncw说道:

    free roulette ventolin pills order allergy pills

  69. Unuwip说道:

    pantoprazole 40mg cost pantoprazole 20mg usa order pyridium for sale

  70. Gonoyr说道:

    casino game poker sites furosemide order online

  71. Cyjvfk说道:

    buy atorvastatin 10mg generic cost albuterol amlodipine price

  72. Jhlssc说道:

    order generic azipro 500mg buy cheap azipro order neurontin 600mg online

  73. Cbiigx说道:

    order generic isotretinoin purchase accutane sale buy zithromax 500mg generic

  74. Pyyxnl说道:

    order omnicef 300mg sale buy prevacid 30mg without prescription cheap lansoprazole 15mg

  75. Ppxyzd说道:

    buy provigil 100mg online cheap buy phenergan tablets deltasone 5mg tablet

  76. Jlpoly说道:

    buy cenforce 100mg without prescription chloroquine without prescription aralen us

  77. Syzcuy说道:

    cialis for daily use tadalafil medication buy sildenafil

  78. Ffhvjf说道:

    micardis 80mg usa plaquenil uk generic molnupiravir 200 mg

  79. Qijlcr说道:

    order prilosec 10mg order montelukast 5mg pill metoprolol 100mg usa

  80. Hwcenw说道:

    premarin 0.625mg sale premarin 0.625mg over the counter viagra pharmacy

  81. Ffuizd说道:

    purchase betahistine pills order xalatan sale buy probenecid cheap

  82. Ncstqg说道:

    how to buy latanoprost zovirax eye drops cheap rivastigmine

  83. Cponhp说道:

    vasotec canada lactulose usa buy lactulose without a prescription

  84. Uirnaq说道:

    buy ferrous 100mg sale ferrous sulfate 100mg pills order betapace 40 mg generic

  85. Zmxcrj说道:

    where to buy mestinon without a prescription mestinon 60mg cost rizatriptan 10mg cheap

  86. Likklr说道:

    prasugrel price buy prasugrel pills for sale detrol tablet

  87. Ijpnkf说道:

    etodolac sale cheap pletal 100 mg buy cilostazol paypal

  88. Zclwpe说道:

    fludrocortisone 100 mcg over the counter buy generic fludrocortisone 100 mcg order loperamide 2 mg

  89. Mkihoo说道:

    duphaston online purchase dapagliflozin buy empagliflozin no prescription

  90. Ipmzey说道:

    order melatonin 3mg sale buy danocrine for sale order danazol

  91. Vxlxhc说道:

    buy aspirin medication aspirin 75mg tablet order imiquad creams

  92. Pgjbws说道:

    acarbose 50mg price cheap fulvicin griseofulvin 250mg usa

  93. Hlkphl说道:

    mintop us minoxytop cost free samples of ed pills

  94. Xmppfu说道:

    buy zaditor 1mg generic buy imipramine 75mg online cheap imipramine 75mg pills

  95. Beodyf说道:

    brand tadalafil viagra 100mg pills viagra professional

  96. Dpnygf说道:

    order tricor 160mg pills buy fenofibrate generic oral fenofibrate

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

CAPTCHAis initialing...