简体   繁体   English

MySQL从另一个表添加列(无参考ID)

[英]Mysql add column from another table (no reference id)

Table small contains 包含
column A varchar(10) column B varchar(20)

Table skeleton contains 框架包含
column A varchar(10) column B varchar(20) column C varchar(30) column D varchar(40)

I want to add column C varchar(30) from table skeleton to small table. 我想将C列varchar(30)从表框架添加表。

Please note skeleton contains no data and two table doesn't have any common key to join. 请注意, 骨架不包含任何数据,并且两个表没有任何公共键可以联接。

@Ultimater thanks.. but that will not solve the issue.. Actually I don't know which column will be needed to add, it will be based on source data.... small table is actually a dynamic table which will grow in times.... skeleton table is like a schema table to get exact column name and type from it. @Ultimater谢谢..但这不能解决问题。.实际上我不知道需要添加哪一列,它将基于源数据.... 表实际上是一个动态表,将在其中增长次...。骨架表就像一个模式表,用于从中获取确切的列名和类型。 Hope you understand.... 希望你能理解....

@update my data feed for small table will be an XML file I do have XSD file also... so if anybody could give any XSD reader library for PHP other than xsdreader - (which I tried without much success) then it will equally solve my problem... Hope You Understand. @update我的小表数据馈送将是一个XML文件,我也有XSD文件...因此,如果有人可以提供xsdreader以外的PHP的任何XSD阅读器库-(我尝试过但没有成功),那么它将同样解决我的问题...希望你理解。

If I understood you correctly, all you're trying to do is add another column to an already existing table. 如果我对您的理解正确,那么您要做的就是在已存在的表中添加另一列。 This is quite simple with phpMyAdmin for example. 例如,这对于phpMyAdmin非常简单。 In your case all you'd need is: 在您的情况下,您需要做的是:

ALTER TABLE  `small` ADD `C` VARCHAR( 30 ) NOT NULL

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

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