简体   繁体   English

新的sql表中不需要的主键

[英]unwanted primary keys in a new sql table

I have bulid a new table in my SQL database with the following command : 我使用以下命令在SQL数据库中建立了一个新表:

Create Table if not exists Images (ImageID int (10) primary key NOT NULL AUTO_INCREMENT , 
         UserID int (10) NOT NULL,
                 Translated tinyint Default 0,
                 DeleteImage tinyint Default 0,
                 DataPosted date,
                 TheImage blob,
                 Translation text,
                 FOREIGN KEY (UserID) REFERENCES Users(UserID) ON DELETE CASCADE)

the table is been created just fine, but what i'm checking what was build i've found out that in the table the columns ImageID, TheImage, and Translation are defined as primary keys. 该表的创建就很好,但是我正在检查的是什么,我发现在表中将ImageID,TheImage和Translation列定义为主键。 as the query is showing I want only the ImageId to be the primary key. 如查询所示,我只希望将ImageId作为主键。

what's happening here? 这里发生了什么事? tnx n

Seems quite unlikely. 似乎不太可能。 It seems far more likely that something is wrong with whatever tool you're using to find out which columns are primary keys. 无论您使用哪种工具来查找哪些列是主键,似乎更有可能出了问题。

Actually, from the documentation - here: http://dev.mysql.com/doc/refman/5.1/en/create-table.html - it would follow that a MySQL table can only have one primary key. 实际上,从文档-这里: http : //dev.mysql.com/doc/refman/5.1/en/create-table.html-可以看出,一个MySQL表只能有一个主键。 But even if not, why would you worry about it? 但是,即使没有,您为什么还要担心呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM