我的英語道歉。我目前正在嘗試在putty中創建一個數據庫,用於我們使用varchar的單詞,但是如果我們想要插入數字呢?例如,我正在創建一個汽車數據庫,其中包括汽車的製造年份,價格,製造和型號。Mysql(使用putty)我如何編寫數字代碼?
什麼是價格正確的語法,我沒有做正確的代碼,因爲我收到一個錯誤?
謝謝!
這是我的代碼:
CREATE TABLE cars(
cars_id int(10) UNSIGNED not null AUTO_INCREMENT PRIMARY KEY,
make VARCHAR(25) not null,
model VARCHAR(25) not null,
price(value) null float,
yom varchar(25) not null
);
MySQL提供了許多數字類型 - 每個都是爲存儲不同大小的數字而設計的。文檔位於http://dev.mysql.com/doc/refman/5.0/en/integer-types.html。例如:price INT,yom TINYINT –
對於貨幣數據使用NUMERIC或DECIMAL.See this [answer](http://stackoverflow.com/questions/13030368/best-data-type-to-store-money-values-in -mysql) –
謝謝你們,幫助我很多,我將不得不更頻繁地檢查mysql手冊。 –