在 MySQL 中實現並設定 DOUBLE 長度


若要在 MySQL 中實現 DOUBLE,語法如下 −

create table yourTableName
     (
     yourColumnName double(5,2) unsigned
);

我們首先建立一個表 −

mysql> create table DemoTable1814
     (
     Amount double(5,2) unsigned
     );
Query OK, 0 rows affected (0.00 sec)

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

mysql> insert into DemoTable1814 values(1.98);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1814 values(100.24);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1814 values(198.50);
Query OK, 1 row affected (0.00 sec)

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

mysql> select * from DemoTable1814;

這將生成以下輸出 −

+--------+
| Amount |
+--------+
|   1.98 |
| 100.24 |
| 198.50 |
+--------+
3 rows in set (0.00 sec)

更新於: 24-Dec-2019

428 的瀏覽量

開啟您的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.