Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 比较多个表的列,一组表具有前缀,并且列数少于另一组表_Sql_Oracle10g - Fatal编程技术网

Sql 比较多个表的列,一组表具有前缀,并且列数少于另一组表

Sql 比较多个表的列,一组表具有前缀,并且列数少于另一组表,sql,oracle10g,Sql,Oracle10g,嗨,我需要比较一组表和另一组表的列。让我解释一下结构。第二组表是从第一组表中提取的,列数较少 TABLE NAMES: W_table_1_fact W_tables_2_fact ......... ........ W_table_n_dim W_table_1_dim W_tables_2_dim ......... ........ W_table_n_dim ABC_W_table_1_fact ABC_W_tables_2_fact ......... ........ ABC_

嗨,我需要比较一组表和另一组表的列。让我解释一下结构。第二组表是从第一组表中提取的,列数较少

TABLE NAMES:
W_table_1_fact
W_tables_2_fact
.........
........
W_table_n_dim
W_table_1_dim
W_tables_2_dim
.........
........
W_table_n_dim


ABC_W_table_1_fact
ABC_W_tables_2_fact
.........
........
ABC_W_table_n_dim
ABC_W_table_1_dim
ABC_W_tables_2_dim
.........
........
ABC_W_table_n_dim

现在,前缀为ABC的表的数据和列都取自原始表,除了少部分缺少的列,可能还有一些数据(暂时不关心)。我需要检查我们需要的列是否已加载到前缀为ABC的表中。因此,我需要进行一个查询,告诉我缺少哪些列。任何人都可以帮助我进行查询。如果您需要任何信息,请随时询问。我将提供任何所需信息。

因此您希望查看列(而不是数据)在源中,但不是整个表列表的目标?您可以对用户选项卡列进行减号。例如:

with tables as
 (select table_name t1, 'ABC_'||table_name t2 --<--- prefixed table 2 based on tables name
    from user_tables 
   where table_name in ('W_TABLE_1_FACT', 'W_TABLES_2_FACT' ))
select t.*,
       cursor (select column_name
                  from user_tab_columns
                 where table_name = t.t1
                minus
                select column_name 
                  from user_tab_columns 
                 where table_name = t.t2) missing_columns
  from tables t
将表作为
(选择表格名称t1,‘ABC’| |表格名称t2--