在 MySQL 中用於儲存大型字串的最佳資料型別是什麼?


可以使用 text 資料型別來儲存大型字串。以下為語法 −

CREATE TABLE yourTableName
(
   yourColumnName text,
   .
   .
   N
);

首先建立一張表 −

mysql> create table DemoTable
   -> (
   -> MyStringValue text
   -> );
Query OK, 0 rows affected (0.67 sec)

使用 insert 命令在表中插入一些記錄 −

mysql> insert into DemoTable values('This is a text data type to store large string'); Query OK, 1 row affected (0.17 sec)

使用 select 語句顯示錶中的所有記錄 −

mysql> select *from DemoTable;

這將生成以下輸出 −

+------------------------------------------------+
| MyStringValue                                  |
+------------------------------------------------+
| This is a text data type to store large string |
+------------------------------------------------+
1 row in set (0.00 sec)

更新於: 2019 年 7 月 30 日

798 次觀看

開啟您的 職業生涯

完成課程取得認證

入門
廣告
© . All rights reserved.