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.
Returns a summary of information on the tables
Shows table information around table row and data sizes and if it has any table type information.
Get-DbaDbTable
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <String[]>]
[[-ExcludeDatabase] <String[]>]
[-IncludeSystemDBs]
[[-Table] <String[]>]
[[-Schema] <String[]>]
[[-InputObject] <Database[]>]
[-EnableException]
[<CommonParameters>]
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Database Test1
Return all tables in the Test1 database
PS C:\> Get-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable
Return only information on the table MyTable from the database MyDB
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
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
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
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
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
The target SQL Server instance or instances. This can be a collection and receive pipeline input.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |
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 |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
Switch parameter that when used will display system database information
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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 |
Only return tables from the specified schema
Alias | |
Required | False |
Pipeline | false |
Default Value |
Enables piping from Get-DbaDatabase
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
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 |