iT邦幫忙

2019 iT 邦幫忙鐵人賽

0
AI & Data

MongoDB 初學者的筆記系列 第 31

資料庫設計III(31)

1.第一個Table建置用的SQL Command

CREATE TABLE `stocks` (
  `StocksDate` date DEFAULT NULL,
  `StocksNo` varchar(100) DEFAULT NULL,
  `StocksTime`time DEFAULT NULL,
  `Price` float DEFAULT null,
  `Buy` float DEFAULT NULL,
  `Sell` float DEFAULT NULL,
  `Fluctuation` varchar(100) DEFAULT NULL,
  `StocksNumber` float DEFAULT NULL,
  `ClosePrice` float DEFAULT NULL,
  `OpenPrice` float DEFAULT NULL,
  `High` float DEFAULT NULL,
  `Low` float DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.建置好Table 後輸入

INSERT INTO  stocks
(StocksDate, StocksNo, StocksTime, Price, Buy, Sell, Fluctuation, StocksNumber, ClosePrice, OpenPrice, High, Low)
VALUES('2018-10-19','2330','14:30','236.0','235.5', '236.0', '▽0.5','28,334','236.5', '231.0', '236.5','230.0');

https://ithelp.ithome.com.tw/upload/images/20181030/20091775YjujpL1TUg.png

  1. 發現錯誤, 檢查後發現是StocksNumber欄位的資料有錯, 資料是 28,334 , 與欄位型態float 不能有逗點, 所以改掉.
    此外, 測試一下日期型態, 2018-10-19 與 2018-10-19 00:00:00 都是可以接受的.
INSERT INTO  stocks
(StocksDate, StocksNo, StocksTime, Price, Buy, Sell, Fluctuation, StocksNumber, ClosePrice, OpenPrice, High, Low)
VALUES('2018-10-19','2330','14:30','236.0','235.5', '236.0', '▽0.5','28334','236.5', '231.0', '236.5','230.0');

https://ithelp.ithome.com.tw/upload/images/20181030/20091775QoAhSbH9Mr.png


上一篇
WEB介面設計-查詢[Read](30)
下一篇
範例下載位置(32)
系列文
MongoDB 初學者的筆記33

尚未有邦友留言

立即登入留言