mysql2000名称_查询表达式和统一资源名称

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

10/14/2020

本文内容

适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) 719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database 719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance 719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics 719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) 719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database 719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance 719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics 719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse719f28649793c602f9270966b5ed5c39.png并行数据仓库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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值