2014-10-01 82 views
0
CREATE TABLE `2m_aperturas_credito` (
    `idaperturacredito` int(10) NOT NULL AUTO_INCREMENT, 
    `nombreapertura` varchar(100) NOT NULL, 
    `activo` int(10) NOT NULL DEFAULT '1', 
    PRIMARY KEY (`idaperturacredito`), 
    KEY `idaperturacredito` (`idaperturacredito`) 
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 

這給了我一個錯誤:無法創建表格。愚蠢的問題,簡單的查詢

[錯誤] 1005 - 無法創建表 'mydb.2m_aperturas_credito'(錯誤:-1)

可以採取什麼錯在這裏??

+4

它對我有用 – 2014-10-01 15:28:54

+0

呃,可能是錯誤的數據庫?你確定你把這個放入「mydb」數據庫嗎?還確定AUTO_INCREMENT爲0或1,不確定。我想你想從1開始數據庫計數嗎? – 2014-10-01 15:30:07

+2

我認爲你不能用一個數字來啓動一個表名,看到這個線程:http://stackoverflow.com/questions/4200351/what-c​​haracters-are-valid-in-an-sql-server-database-name – Groben 2014-10-01 15:31:37

回答

1

Reference manual: Schema Object Names引用:

It is recommended that you do not use names that begin with Me or MeN , where M and N are integers. For example, avoid using 1e as an identifier, because an expression such as 1e+3 is ambiguous. Depending on context, it might be interpreted as the expression 1e + 3 or as the number 1e+3 .

這就是說,作爲一般規則,應避免使用在對象名稱的開始(數據庫,表,列,過程,函數,變量,等等)數字。嘗試創建沒有數字的表格。