I am wanting to create a view using postgresql that essentially shows me all information in the entire database.
Example:
Table 1
- pin
- insert_time
Table 2
- tmr
- insert_time
Table 3
- weight
- insert_time
Desired Output View
- pin 开发者_JAVA百科
- tmr
- weight
- insert_time
The output view would be sorted by insert_time. It would just leave the columns blank that aren't used for that row ie. If it pulled from Table 1 then PIN and insert_time would be filled but tmr and weight would be left blank.
How can I go about doing this? I can create other tables if needed, but not sure how I would do this.
CREATE VIEW everything AS SELECT insert_time, pin, null as tmr, null as weight FROM table_1 UNION ALL SELECT insert_time, null as pin, tmr, null as weight FROM table_2 UNION ALL SELECT insert_time, pin, tmr, weight FROM table_3;
精彩评论