{"id":199639,"date":"2025-05-06T08:16:11","date_gmt":"2025-05-06T00:16:11","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199639\/"},"modified":"2025-05-06T08:16:11","modified_gmt":"2025-05-06T00:16:11","slug":"%e5%a6%82%e4%bd%95%e6%a0%b9%e6%8d%ae%e9%9c%80%e6%b1%82%e6%ad%a3%e7%a1%ae%e9%80%89%e6%8b%a9%e5%90%88%e9%80%82%e7%9a%84mysql%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%ef%bc%9amysql%e6%95%b0%e6%8d%ae%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199639\/","title":{"rendered":"\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684MySQL\u6570\u636e\u7c7b\u578b\uff1aMySQL\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6307\u5357"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684MySQL\u6570\u636e\u7c7b\u578b\uff1aMySQL\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6307\u5357<\/h1>\n<p>IT\u884c\u4e1a\u76f8\u5bf9\u4e8e\u4e00\u822c\u4f20\u7edf\u884c\u4e1a\uff0c\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u66f4\u5feb\uff0c\u4e00\u65e6\u505c\u6b62\u4e86\u5b66\u4e60\uff0c\u5f88\u5feb\u5c31\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8e0f\u8e0f\u5b9e\u5b9e\u7684\u4e0d\u65ad\u5b66\u4e60\uff0c\u7cbe\u8fdb\u81ea\u5df1\u7684\u6280\u672f\uff0c\u5c24\u5176\u662f\u521d\u5b66\u8005\u3002\u4eca\u5929\u4e3b\u673a\u5b9d\u8d1d\u7ed9\u5927\u5bb6\u6574\u7406\u4e86\u300a\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684MySQL\u6570\u636e\u7c7b\u578b\uff1aMySQL\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6307\u5357\u300b\uff0c\u804a\u804a\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01<\/p>\n<p>MySQL\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6307\u5357\uff1a\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\uff0c\u9700\u8981\u5177\u4f53\u4ee3\u7801\u793a\u4f8b<\/p>\n<p>\u5f15\u8a00\uff1a<br \/>\u5728\u4f7f\u7528MySQL\u6570\u636e\u5e93\u65f6\uff0c\u6570\u636e\u7c7b\u578b\u7684\u9009\u62e9\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u5b58\u50a8\u6548\u7387\uff0c\u8fd8\u53ef\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u51c6\u786e\u6027\u548c\u5b8c\u6574\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u7528\u7684MySQL\u6570\u636e\u7c7b\u578b\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u8bfb\u8005\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p>\u4e00\u3001\u6574\u6570\u7c7b\u578b<br \/>MySQL\u63d0\u4f9b\u4e86\u591a\u79cd\u6574\u6570\u7c7b\u578b\uff0c\u901a\u5e38\u6839\u636e\u6570\u636e\u8303\u56f4\u548c\u5b58\u50a8\u9700\u6c42\u9009\u62e9\u3002<\/p>\n<ol>\n<li>\n<p>TINYINT\uff1a\u5360\u75281\u4e2a\u5b57\u8282\uff0c\u8303\u56f4\u4e3a-128~127\u62160~255\u3002<\/p>\n<pre>CREATE TABLE `user` (\n  `id` TINYINT UNSIGNED NOT NULL PRIMARY KEY,\n  `name` VARCHAR(50) NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>SMALLINT\uff1a\u5360\u75282\u4e2a\u5b57\u8282\uff0c\u8303\u56f4\u4e3a-32768~32767\u62160~65535\u3002<\/p>\n<pre>CREATE TABLE `order` (\n  `order_id` SMALLINT UNSIGNED NOT NULL PRIMARY KEY,\n  `total_amount` DECIMAL(8,2) NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>MEDIUMINT\uff1a\u5360\u75283\u4e2a\u5b57\u8282\uff0c\u8303\u56f4\u4e3a-8388608~8388607\u62160~16777215\u3002<\/p>\n<pre>CREATE TABLE `product` (\n  `product_id` MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY,\n  `price` DECIMAL(10,2) NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>INT\uff1a\u5360\u75284\u4e2a\u5b57\u8282\uff0c\u8303\u56f4\u4e3a-2147483648~2147483647\u62160~4294967295\u3002<\/p>\n<pre>CREATE TABLE `customer` (\n  `customer_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `name` VARCHAR(100) NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>BIGINT\uff1a\u5360\u75288\u4e2a\u5b57\u8282\uff0c\u8303\u56f4\u4e3a-9223372036854775808~9223372036854775807\u62160~18446744073709551615\u3002<\/p>\n<pre>CREATE TABLE `transaction` (\n  `transaction_id` BIGINT UNSIGNED NOT NULL PRIMARY KEY,\n  `amount` DECIMAL(12,2) NOT NULL\n);<\/pre>\n<\/li>\n<\/ol>\n<p>\u4e8c\u3001\u6d6e\u70b9\u7c7b\u578b<br \/>MySQL\u63d0\u4f9b\u4e86\u6d6e\u70b9\u7c7b\u578b\u6765\u5b58\u50a8\u5e26\u6709\u5c0f\u6570\u70b9\u7684\u6570\u503c\uff0c\u6839\u636e\u7cbe\u5ea6\u8981\u6c42\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<ol>\n<li>\n<p>FLOAT\uff1a\u5360\u75284\u4e2a\u5b57\u8282\uff0c\u7cbe\u5ea6\u4e3a\u5355\u7cbe\u5ea6\uff0c\u9002\u7528\u4e8e\u5b58\u50a8\u8303\u56f4\u8f83\u5927\u4f46\u7cbe\u5ea6\u8981\u6c42\u4e0d\u9ad8\u7684\u6570\u636e\u3002<\/p>\n<pre>CREATE TABLE `student` (\n  `student_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `name` VARCHAR(100) NOT NULL,\n  `score` FLOAT NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>DOUBLE\uff1a\u5360\u75288\u4e2a\u5b57\u8282\uff0c\u7cbe\u5ea6\u4e3a\u53cc\u7cbe\u5ea6\uff0c\u9002\u7528\u4e8e\u5b58\u50a8\u7cbe\u5ea6\u8981\u6c42\u8f83\u9ad8\u7684\u6570\u636e\u3002<\/p>\n<pre>CREATE TABLE `product` (\n  `product_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `name` VARCHAR(100) NOT NULL,\n  `price` DOUBLE NOT NULL\n);<\/pre>\n<\/li>\n<\/ol>\n<p>\u4e09\u3001\u5b57\u7b26\u4e32\u7c7b\u578b<br \/>MySQL\u63d0\u4f9b\u4e86\u591a\u79cd\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u6839\u636e\u5b58\u50a8\u9700\u6c42\u548c\u6570\u636e\u957f\u5ea6\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<ol>\n<li>\n<p>CHAR\uff1a\u56fa\u5b9a\u957f\u5ea6\u5b57\u7b26\u4e32\uff0c\u6700\u957f\u53ef\u5b58\u50a8255\u4e2a\u5b57\u7b26\u3002<\/p>\n<pre>CREATE TABLE `user` (\n  `user_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `username` CHAR(50) NOT NULL,\n  `password` CHAR(32) NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>VARCHAR\uff1a\u53ef\u53d8\u957f\u5ea6\u5b57\u7b26\u4e32\uff0c\u6700\u957f\u53ef\u5b58\u50a865535\u4e2a\u5b57\u7b26\u3002<\/p>\n<pre>CREATE TABLE `article` (\n  `article_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `title` VARCHAR(100) NOT NULL,\n  `content` TEXT NOT NULL\n);<\/pre>\n<\/li>\n<\/ol>\n<p>\u56db\u3001\u65e5\u671f\u548c\u65f6\u95f4\u7c7b\u578b<br \/>MySQL\u63d0\u4f9b\u4e86\u65e5\u671f\u548c\u65f6\u95f4\u7c7b\u578b\u6765\u5b58\u50a8\u65e5\u671f\u3001\u65f6\u95f4\u548c\u65f6\u95f4\u6233\u7b49\u6570\u636e\u3002<\/p>\n<ol>\n<li>\n<p>DATE\uff1a\u5b58\u50a8\u65e5\u671f\uff0c\u683c\u5f0f\u4e3aYYYY-MM-DD\u3002<\/p>\n<pre>CREATE TABLE `employee` (\n  `employee_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `name` VARCHAR(100) NOT NULL,\n  `hire_date` DATE NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>TIME\uff1a\u5b58\u50a8\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3aHH:MM:SS\u3002<\/p>\n<pre>CREATE TABLE `message` (\n  `message_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `content` TEXT NOT NULL,\n  `create_time` TIME NOT NULL\n);<\/pre>\n<\/li>\n<li>\n<p>DATETIME\uff1a\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3aYYYY-MM-DD HH:MM:SS\u3002<\/p>\n<pre>CREATE TABLE `log` (\n  `log_id` INT UNSIGNED NOT NULL PRIMARY KEY,\n  `message` TEXT NOT NULL,\n  `create_datetime` DATETIME NOT NULL\n);<\/pre>\n<\/li>\n<\/ol>\n<p>\u603b\u7ed3\uff1a<br \/>\u5728MySQL\u6570\u636e\u5e93\u4e2d\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u5bf9\u4e8e\u5b58\u50a8\u548c\u5904\u7406\u6570\u636e\u90fd\u975e\u5e38\u91cd\u8981\u3002\u901a\u8fc7\u5408\u7406\u9009\u62e9\u6574\u6570\u7c7b\u578b\u3001\u6d6e\u70b9\u7c7b\u578b\u3001\u5b57\u7b26\u4e32\u7c7b\u578b\u4ee5\u53ca\u65e5\u671f\u548c\u65f6\u95f4\u7c7b\u578b\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u3001\u51c6\u786e\u6027\u548c\u5b58\u50a8\u6548\u7387\u3002\u672c\u6587\u63d0\u4f9b\u4e86\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u8bfb\u8005\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u6b63\u786e\u9009\u62e9\u6570\u636e\u7c7b\u578b\u3002\u8bfb\u8005\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u5e94\u6839\u636e\u81ea\u5df1\u7684\u5177\u4f53\u60c5\u51b5\u8fdb\u884c\u5224\u65ad\u548c\u9009\u62e9\uff0c\u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u6570\u636e\u5e93\u8bbe\u8ba1\u548c\u6027\u80fd\u4f18\u5316\u6548\u679c\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684MySQL\u6570\u636e\u7c7b\u578b\uff1aMySQL\u6570\u636e\u7c7b\u578b\u9009\u62e9\u6307\u5357\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u6570\u636e\u7c7b\u578b\u9009\u62e9,MySQL\u6570\u636e\u7c7b\u578b,\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u6839\u636e\u9700\u6c42\u6b63\u786e\u9009\u62e9\u5408\u9002\u7684MyS&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-199639","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199639"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199639\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}