Subscribe

Cross database foreign key (playground, cm_storage)

Hi


I made a custom playground table with the rows vserver_id, volume_id and info.

I want to use this table to save specific info for every volume, which I can later use to filter the volumes.

Is there any way I can link the rows vserver_id and volume_id with the tabels in cm_storage? So I can make SQL statements with JOIN between the tables to get the information.

I tried it with foreign keys but it didn't work (my SQL knowledge is not the best).

I'm running WFA 4.0 on Linux

 

Regards,

Simon

Re: Cross database foreign key (playground, cm_storage)

Hi Simon,

 

As per my understanding, I have written query for connecting cm-storage scheme from playground scheme to collect vserver and volume details.

Hope it will resolve your issue. If not please explain complete details.

 

 

insert into playground.test (VolumeID,VserverID,VolumeInfo) VALUES (

(SELECT

volume.id AS 'vollume id'

 

FROM

cm_storage.cluster,

cm_storage.vserver,

cm_storage.volume

 

WHERE

vserver.cluster_id = cluster.id

AND volume.vserver_id = vserver.id

AND volume.name = 'TEST_VOLUME'

AND cluster.primary_address = '10.140.110.165'

),

 

(SELECT

vserver.id AS 'vserver id'

 

FROM

cm_storage.cluster,

cm_storage.vserver

 

WHERE

vserver.cluster_id = cluster.id

 

AND vserver.name = 'VS1'

AND cluster.primary_address = '10.140.110.165'

),

 

"volcode"

  )

 

 

Best Regards,

Shiva