看板 Database 關於我們 聯絡資訊
※ 引述《Biboy (栗子)》之銘言: : create table ordered : ( mem_id char(10) not null, : ordered_album char(30) not null, : price integer, : check(price>0) : ); : 這是我create的table : 如果輸入的金額為0以下就不能新增 : 可是我輸入下面那行指令時,還是可以輸入,不會有error出現 : insert into ordered values('AK123','New World',-20); : 如果依造限制條件,應該是不能輸入阿 : 請問這是哪裡出了問題?? http://forums.mysql.com/read.php?35,48832,48832#msg-48832 如果只是要求大於零,可以考慮用 UNSIGNED 。 老實說,用程式先做好判斷會比較好,錯誤發生時,顯示的頁面跟訊息能自行控制。 -- ╥╥╖╓─╥╖ ╓─╥╖╓╖ ╓─╥╖ ╓─╥╖ ╓╖╓╖ ╟╢ ╟╢ ╙╜ ╟╢╟╢ ╟╢ ║║╟╢ ╟╢ ╟╢ ╟─ ╟─╫╢ ╟╢ ╟─╫╜ ║║╟╢ ╟╢ ╟╢ ╓╖ ╟╢╟╢ ║║╟╢ ╨╜ ╙─╨╜ ╙─╨╜ ╙╜ ╙─╨╜╙╜ ╙╙╨╜ 獅子男 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.18.56.221
Biboy:請問型態就是 "unsigned" 嗎? 我剛剛測試會出錯~ 06/06 20:52