查询表达式和统一资源名称Query Expressions and Uniform Resource Names

10/14/2020

本文内容

适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) Azure SQL 数据库Azure SQL DatabaseAzure SQL 数据库Azure SQL Database Azure SQL 托管实例Azure SQL Managed InstanceAzure SQL 托管实例Azure SQL Managed Instance Azure Synapse AnalyticsAzure Synapse AnalyticsAzure Synapse AnalyticsAzure Synapse Analytics 并行数据仓库Parallel Data Warehouse并行数据仓库Parallel Data Warehouse适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) Azure SQL 数据库Azure SQL DatabaseAzure SQL 数据库Azure SQL Database Azure SQL 托管实例Azure SQL Managed InstanceAzure SQL 托管实例Azure SQL Managed Instance Azure Synapse AnalyticsAzure Synapse AnalyticsAzure Synapse AnalyticsAzure Synapse Analytics 并行数据仓库Parallel Data Warehouse并行数据仓库Parallel Data Warehouse

SQL ServerSQL Server 管理对象 (SMO) 模型和 SQL ServerSQL Server PowerShell 管理单元使用与 XPath 表达式相似的两种类型的表达式。The SQL ServerSQL Server Management Object (SMO) models and SQL ServerSQL Server PowerShell snap-ins use two types of expression strings that are similar to XPath expressions. 查询表达式是指定一组条件的字符串,用于枚举对象模型层次结构中的一个或多个对象。Query expressions are strings that specify a set of criteria used to enumerate one or more objects in an object model hierarchy. 统一资源名称 (URN) 是一种特定类型的查询表达式字符串,用于唯一标识单个对象。A Uniform Resource Name (URN) is a specific type of query expression string that uniquely identifies a single object.

备注

SQL Server PowerShell 模块有两种;SqlServer 和 SQLPS 。There are two SQL Server PowerShell modules; SqlServer and SQLPS.

SqlServer 模块是当前要使用的 PowerShell 模块。The SqlServer module is the current PowerShell module to use.

虽然 SQL Server 安装附带了 SQLPS 模块(用于实现后向兼容性),但该模块不再更新。The SQLPS module is included with the SQL Server installation (for backward compatibility) but is no longer updated.

SqlServer 模块不仅包含 SQLPS 更新版本的 cmdlet,还包含新的 cmdlet 以支持最新的 SQL 功能 。The SqlServer module contains updated versions of the cmdlets in SQLPS and includes new cmdlets to support the latest SQL features.

从 PowerShell 库安装 SqlServer 模块。Install the SqlServer module from the PowerShell Gallery.

语法Syntax

Object1[]/ ... /ObjectN[]

::=

[and ][...n]

::=

@BooleanPropertyName=true()

| @BooleanPropertyName=false()

| contains(@StringPropertyName, 'PatternString')

| @StringPropertyName='String'

| @DatePropertyName=datetime('DateString')

| is_null(@PropertyName)

| not()

自变量Arguments

ObjectObject

指定在表达式字符串的节点表示的对象的类型。Specifies the type of object that is represented at that node of the expression string. 每个对象表示那些 SMO 对象模型名称空间中的一个集合类:Each object represents a collection class from these SMO object model namespaces:

例如,为 ServerCollection 类指定“服务器”,为 DatabaseCollection 类指定“数据库”。For example, specify Server for the ServerCollection class, Database for the DatabaseCollection class.

@PropertyName@PropertyName

指定与“对象”中指定的对象相关联的类的其中一个属性的名称。Specifies the name of one of the properties of the class that is associated with the object specified in Object. 属性名必须以字符 @ 为前缀。The name of the property must be prefixed with the @ character. 例如,对 Database 类的 IsAnsiNull 属性指定 @IsAnsiNull。For example, specify @IsAnsiNull for the Database class property IsAnsiNull.

@BooleanPropertyName=true()@BooleanPropertyName=true()

枚举指定的布尔属性设置为 TRUE 的所有对象。Enumerates all objects where the specified Boolean property is set to TRUE.

@BooleanPropertyName=false()@BooleanPropertyName=false()

枚举指定的布尔属性设置为 FALSE 的所有对象。Enumerates all objects where the specified Boolean property is set to FALSE.

contains(@StringPropertyName, 'PatternString')contains(@StringPropertyName, 'PatternString')

枚举指定的字符串属性中包含“PatternString”中指定的一组字符(至少出现一次)的所有对象。Enumerates all objects where the specified string property contains at least one occurrence of the set of characters that is specified in 'PatternString'.

@StringPropertyName='PatternString'@StringPropertyName='PatternString'

枚举指定字符串属性的值与在“PatternString”中指定的字符模式完全相同的所有对象。Enumerates all objects where the value of the specified string property is exactly the same as the character pattern that is specified in 'PatternString'.

@DatePropertyName= datetime('DateString')@DatePropertyName= datetime('DateString')

枚举指定日期属性的值与在“DateString”中指定的日期相匹配的所有对象。Enumerates all objects where the value of the specified date property matches the date that is specified in 'DateString'. DateString 必须遵循格式 yyyy-mm-dd hh:mi:ss.mmm。DateString must follow the format yyyy-mm-dd hh:mi:ss.mmm.

DateString 组件DateString component

说明Description

yyyyyyyy

四位数年份。Four digit year.

mmmm

两位数月份(01 到 12)。Two digit month (01 through 12).

dddd

两位数日期(01 到 31)。Two digit date (01 through 31).

hhhh

24 小时制的两位数小时(01 到 23)。Two digit hour using a 24-hour clock (01 through 23).

mimi

两位数分钟(01 到 59)。Two digit minutes (01 through 59).

ssss

两位数秒数(01 到 59)。Two digit seconds (01 through 59).

mmmmmm

毫秒数(001 到 999)。Number of milliseconds (001 through 999).

可以按照存储在 SQL ServerSQL Server中的任何日期格式,计算以此格式指定的日期。The dates that are specified in this format can be evaluated against any date format that is stored in SQL ServerSQL Server.

is_null(@PropertyName)is_null(@PropertyName)

枚举指定属性的值为 NULL 的所有对象。Enumerates all objects where the specified property has a value of NULL.

not()not()

对 PropertyExpression的计算值求反,枚举与 PropertyExpression中指定的条件不匹配的所有对象。Negates the evaluation value of the PropertyExpression, enumerating all objects that do not match the condition specified in PropertyExpression. 例如,not(contains(@Name, 'xyz')) 枚举名称中不含字符串 xyz 的所有对象。For example, not(contains(@Name, 'xyz')) enumerates all objects that do not have the string xyz in their names.

备注Remarks

查询表达式是一些字符串,用于枚举 SMO 模型层次结构中的节点。Query expressions are strings that enumerate the nodes in an SMO model hierarchy. 每个节点有一个筛选表达式,指定用于确定要枚举该节点的哪些对象的条件。Each node has a filter expression that specifies the criteria for determining which objects at that node are enumerated. 查询表达式在 XPath 表达式语言上建模。Query expressions are modeled on the XPath expression language. 查询表达式实现了 XPath 支持的一小部分表达式,还具有 XPath 中不提供的一些扩展。Query expressions implement a small subset of the expressions that are supported by XPath, and also have some extensions that are not found in XPath. XPath 表达式是一些字符串,指定用于枚举 XML 文档中的一个或多个标记的一组条件。XPath expressions are strings that specify a set of criteria that are used to enumerate one or more of the tags in an XML document. 有关 XPath 的详细信息,请参阅 W3C XPath Language(W3C Xpath 语言)。For more information about XPath, see W3C XPath Language.

查询表达式必须以对服务器对象的绝对引用开头。Query expressions must start with an absolute reference to the Server object. 不允许使用以 / 开头的相对表达式。Relative expressions with a leading / are not allowed. 查询表达式中指定的对象的顺序必须遵循相关对象模型中集合对象的层次结构。The sequence of objects that are specified in a query expression must follow the hierarchy of collection objects in the associated object model. 例如,引用 Microsoft.SqlServer.Management.Smo 命令空间中对象的查询表达式必须从服务器节点开始,接下来才是数据库节点等。For example, a query expression that references objects in the Microsoft.SqlServer.Management.Smo namespace must start with a Server node followed by a Database node, and so on.

如果没有为对象指定 ,将枚举该节点的所有对象。If a is not specified for an object, all the objects at that node are enumerated.

统一资源名称 (URN)Uniform Resource Names (URN)

URN 是查询表达式的子集。URNs are a subset of query expressions. 每个 URN 形成对单个对象的完全限定引用。Each URN forms a fully-qualified reference to a single object. 典型的 URN 使用 Name 属性来标识每个节点的单个对象。A typical URN uses the Name property to identify a single object at each node. 例如,该 URN 引用一个特定列:For example, this URN refers to a specific column:

Server[@Name='MYCOMPUTER']/Database[@Name='AdventureWorks2012']/Table[@Name='SalesPerson' and @Schema='Sales']/Column[@Name='SalesPersonID']

示例Examples

A.A. 使用 false() 枚举对象Enumerating objects using false()

此查询表达式枚举 MyComputer 上默认实例中 AutoClose属性设置为 False 的所有数据库。This query expression enumerates all the databases that have the AutoClose attribute set to false in the default instance on MyComputer.

Server[@Name='MYCOMPUTER']/Database[@AutoClose=false()]

B.B. 使用 contains 枚举对象Enumerating objects using contains

此查询表达式枚举所有区分大小写、并且名称中包含“m”的数据库。This query expression enumerates all the databases that are case-insensitive and have the character 'm' in their name.

Server[@Name='MYCOMPUTER']/Database[@CaseSensitive=false() and contains(@Name, 'm')]

C.C. 使用 not 枚举对象Enumerating objects using not

此查询表达式枚举不在 AdventureWorks2012AdventureWorks2012 Production 架构中、而且表名中包含“History”一词的所有 表:This query expression enumerates all of AdventureWorks2012AdventureWorks2012 tables that are not in the Production schema and contain the word History in the table name:

Server[@Name='MYCOMPUTER']/Database[@Name='AdventureWorks2012']/Table[not(@Schema='Production') and contains(@Name, 'History')]

D.D. 不为最终节点提供筛选表达式Not supplying a filter expression for the final node

此查询表达式枚举 AdventureWorks2012.Sales.SalesPerson 表中的所有列:This query expression enumerates all the columns in the AdventureWorks2012.Sales.SalesPerson table:

Server[@Name='MYCOMPUTER']/Database[@Name='AdventureWorks2012"]/Table[@Schema='Sales' and @Name='SalesPerson']/Columns

E.E. 使用 datetime 枚举对象Enumerating objects using datetime

此查询表达式枚举 AdventureWorks2012AdventureWorks2012 数据库中于特定时间创建的所有表:This query expression enumerates all the tables that are created in the AdventureWorks2012AdventureWorks2012 database at a specific time:

Server[@Name='MYCOMPUTER']/Database[@Name='AdventureWorks2012"]/Table[@CreateDate=datetime('2008-03-21 19:49:32.647')]

F.F. 使用 is_null 枚举对象Enumerating objects using is_null

此查询表达式枚举 AdventureWorks2012AdventureWorks2012 数据库中上次修改日期属性不为 Null 的所有表:This query expression enumerates all the tables in the AdventureWorks2012AdventureWorks2012 database that do not have NULL for their date last modified property:

Server[@Name='MYCOMPUTER']/Database[@Name='AdventureWorks2012"]/Table[Not(is_null(@DateLastModified))]

另请参阅See Also

mysql2000名称_查询表达式和统一资源名称相关推荐

  1. URL,URI,URN三者的区别和联系(统一资源定、统一资源标识符、统一资源名称)

    1.URL(统一资源定位符--Uniform Resource Locator): 指向Internet中位于某个主机上的资源,通常由四部分组成: 协议名称(常为HTTP) 页面所在主机的的DNS名或 ...

  2. oracle语句mysql数据库名称_查询oracle数据库中当前数据库所有表的名称

    SQL查询数据库中所有指定类型的字段名称和所在的表名 --查询数据库中所有指定类型的字段名称和所在的表名 --eg: 下面查的是当前数据库中 所有字段类型为 nvarchar(max) 的字段名和表名 ...

  3. python更改进程名称_更改python脚本的进程名称 - python

    有没有办法更改在Linux上运行python脚本的进程的名称? 当我执行ps时,我得到的只是"python"进程名称. 参考方案 http://code.google.com/p/ ...

  4. win10怎么更改账户名称_如何更改电脑系统账户名称?让你的名称看起来高大上,快来学习吧...

    随着日常生活水平的提高,生活中大家已离不开电脑手机等设备,那么,对于你每天在使用的电脑各方面有没有看似不顺眼之处呢? 譬如:电脑系统账户名称,为了防止他人偷窃设置加密,锁屏状态下显示的系统名称却还是默 ...

  5. java 字体名称_如何从Java获取字体名称列表

    在Java中,我们可以创建一个Font对象: new Font("Helvetica", Font.PLAIN, 12); 我的问题是如何从Java中获取整个字体名称列表,例如&q ...

  6. ubuntu如何查看网卡名称_在 ubuntu 中修改网卡名称

    ip a 记下网卡名称和对应的MAC sudo vi /etc/udev/rules.d/70-persistent-net.rules # PCI device 0x1022:0x2000 (pcn ...

  7. [深入学习C#]LINQ查询表达式详解(2)——查询表达式的转换

    转载自诗人江湖老,原文地址 C#在执行LINQ查询表达式的时候,并不会指定其执行语义,而是将查询表达式转换为遵循查询表达式模式的方法的调用.具体而言,查询表达式将转换为以下名称的调用:Where.Se ...

  8. Android中资源id的获取,根据id获取资源以及根据资源名称获取id。

    1.如何获取资源id        layout布局中: @资源类型/资源名       java代码实现: R.资源类型.资源名    2.如何根据id获取资源       getResources ...

  9. mysql 查询不为0的数据_查询数据库中所有记录总数不为0的数据表名称

    [如何查询postgreSQL 里面某个数据库中所有用户定义的数据表的名字@forandever 2011-11-131.通过命令行查询\d 数据库  -- 得到所有表的名字\d 表名  -- 得到表 ...

最新文章

  1. 分布式训练使用手册-paddle 数据并行
  2. python3.7新功能_2018-11-08安装Python3.7详解
  3. footer始终在页面最底部的方法(问题待检验)
  4. java linux文件夹大小_Linux_Linux文件夹大小查看办法, 1. du -sh查看当前文件 - phpStudy...
  5. python+xlrd+xlwt操作excel
  6. Build a Machine Learning Portfolio(构建机器学习投资组合)
  7. [Oracle]UNIX与Windows 2000上Oracle的差异(I)
  8. (王道408考研操作系统)第三章内存管理-第二节4:页面分配策略
  9. fate框架找不到 flow 命令
  10. IOS 使用webview 显示 doc/docx/xls/pdf等
  11. matlab compass函数,Matlab基本函数-compass函数 | 学步园
  12. w3cschool实战答案
  13. 银行业9大数据科学应用案例
  14. matlab中wavread函数错误改用方法
  15. 5菜鸟教程_【菜鸟手册7】如何在NVIDIA Jetson平台上安装Anaconda
  16. wince 之临时宏控制 bib 和 reg
  17. Linux收音机软件,在Linux终端听收音机
  18. 如何用python进行数据处理?(二)
  19. 微信小程序九宫格抽奖
  20. BooT模式: Flash、ISP、SRAM

热门文章

  1. 推荐一个很不错的刷题网站
  2. create_ap遇到的问题
  3. php smarty使用,php-smarty模板使用教程(二)
  4. Web开发——服务器端应用技术简单比较
  5. 【Spring】Spring复习之基础和IOC
  6. centos vscode安装到指定目录_centos7 安装和运行在线vscode
  7. Matlab字体设置中找不到字体
  8. 揭秘!服务器机房都有哪些重要的系统?
  9. ESP8266-Arduino编程实例-BMA250加速度传感器驱动
  10. 7、公司上市 - 开公司创业系列文章