视图和表的集体名称/类型?

时间:2018-09-05 14:31:05

标签: sql sql-server

我想创建一个数据库表,该表的一列存储表或视图的名称。调用我的列“ ViewOrTableName”似乎有点笨拙。是否有通用的类型/名称,可能表示“表”或“视图”?

具体来说,如果语言不同,我将在MS SQL中执行此操作。

1 个答案:

答案 0 :(得分:2)

T-SQL documentation for FROM

  

FROM(Transact-SQL)

     

指定表,视图,派生表和联接表   SQL Server 2017中的DELETE,SELECT和UPDATE语句。

     

语法

[ FROM { <table_source> } [ ,...n ] ]   
<table_source> ::=   
{  
    table_or_view_name [ [ AS ] table_alias ]   
        [ <tablesample_clause> ]   
        [ WITH ( < table_hint > [ [ , ]...n ] ) ]   
    | rowset_function [ [ AS ] table_alias ]   
        [ ( bulk_column_alias [ ,...n ] ) ]   
    | user_defined_function [ [ AS ] table_alias ]  
    | OPENXML <openxml_clause>   
    | derived_table [ [ AS ] table_alias ] [ ( column_alias [ ,...n ] ) ]   
    | <joined_table>   
    | <pivoted_table>   
    | <unpivoted_table>  
    | @variable [ [ AS ] table_alias ]  
    | @variable.function_call ( expression [ ,...n ] )   
        [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]  
    | FOR SYSTEM_TIME <system_time>   
}

因此,也许您想使用 table_source table_or_view_name