commands

^

Get-DbaDbTable

Author Stephen Bennett, sqlnotesfromtheunderground.wordpress.com
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaDbTable on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbTable.

Synopsis

Returns a summary of information on the tables

Description

Shows table information around table row and data sizes and if it has any table type information.

Syntax

Get-DbaDbTable
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [[-ExcludeDatabase] <String[]>]
    [-IncludeSystemDBs]
    [[-Table] <String[]>]
    [[-Schema] <String[]>]
    [[-InputObject] <Database[]>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Database Test1

Return all tables in the Test1 database

Example: 2
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable

Return only information on the table MyTable from the database MyDB

Example: 3
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable -Schema MySchema

Return only information on the table MyTable from the database MyDB and only from the schema MySchema

Example: 4
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Table MyTable

Returns information on table called MyTable if it exists in any database on the server, under any schema

Example: 5
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Table dbo.[First.Table]

Returns information on table called First.Table on schema dbo if it exists in any database on the server

Example: 6
PS C:\> 'localhost','localhost\namedinstance' | Get-DbaDbTable -Database DBA -Table Commandlog

Returns information on the CommandLog table in the DBA database on both instances localhost and the named instance localhost\namedinstance

Example: 7
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Table "[[DbName]]].[Schema.With.Dots].[`"[Process]]`"]" -Verbose

Return table information for instance Dev01 and table Process with special characters in the schema name

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. This can be a collection and receive pipeline input.

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Database

The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.

Alias
Required False
Pipeline false
Default Value
-ExcludeDatabase

The database(s) to exclude - this list is auto-populated from the server

Alias
Required False
Pipeline false
Default Value
-IncludeSystemDBs

Switch parameter that when used will display system database information

Alias
Required False
Pipeline false
Default Value False
-Table

Define a specific table you would like to query. You can specify up to three-part name such as db.sch.tbl.
If the object has special characters wrap them in square brackets [ ].
The correct way to find table named 'First.Table' on schema 'dbo' is by passing dbo.[First.Table]
Any actual usage of the ] must be escaped by duplicating the ] character.
The correct way to find a table Name] in schema Schema.Name is by passing [Schema.Name].[Name]]]

Alias
Required False
Pipeline false
Default Value
-Schema

Only return tables from the specified schema

Alias
Required False
Pipeline false
Default Value
-InputObject

Enables piping from Get-DbaDatabase

Alias
Required False
Pipeline true (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False