简体   繁体   English

如何在Oracle 10g数据库中连接两个表?

[英]How to connect two tables in oracle 10g database?

I have table named REGISTRATION with fields like ID, NAME, PASSWORD, USERNAME . 我有名为REGISTRATION表,其中包含ID, NAME, PASSWORD, USERNAME等字段。 I want to make another table named PHOTOS with fields ID, TITLE, PHOTO . 我要创建另一个名为PHOTOS表,其字段ID, TITLE, PHOTO The thing I want to ask is that I want the ID field of the PHOTOS table should match with the ID field of the REGISTRATION table. 我要问的事情是,我想要的ID基于场PHOTOS表应与匹配ID在现场REGISTRATION表。 Whenever there is any entry in the REGISTRATION table the content of ID field gets copied into the ID field of PHOTOS table....?? 只要REGISTRATION表中有任何条目, ID字段的内容就会复制到PHOTOS表的ID字段中。

If you have only one photo per user, then yes, it is a good idea to make ID the same. 如果每个用户只有一张照片,那么可以,使ID相同是个好主意。 But then why it is not just one table that contains info from registration and photos? 但是,为什么它不只是一张包含注册和照片信息的表呢?

if you have multiply photos per user, then no. 如果每个用户拥有多张照片,则不会。 ID usually recognized as unique identifier of a record in a table (2 records in the same table have different IDs). 通常将ID识别为表中记录的唯一标识符(同一表中的2条记录具有不同的ID)。 So instead of using ID for user, you use UserId as an additional column in PHOTOS table. 因此,您可以将UserId用作PHOTOS表中的附加列,而不是为用户使用ID。

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

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