Creates a synonym.
Add-Synonym [-Name] <String> [-SchemaName <String>] [-TargetDatabaseName <String>] [-TargetSchemaName <String>] [-TargetObjectName] <String> [<CommonParameters>]
SQL Server lets you create synonyms so you can reference an object with a different name, or reference an object in another database with a local name.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Name | String | The name of the synonym. |
true | false | |
SchemaName | String | The name of the schema where the synonym should be created. |
false | false | dbo |
TargetDatabaseName | String | The database where the target object is located. Defaults to the current database. |
false | false | |
TargetSchemaName | String | The scheme of the target object. Defaults to |
false | false | dbo |
TargetObjectName | String | The target object's name the synonym will refer to. |
true | false |
Add-Synonym -Name 'Buzz' -TargetObjectName 'Fizz'
Creates a synonym called Buzz
to the object Fizz
.
Add-Synonym -SchemaName 'fiz' -Name 'Buzz' -TargetSchemaName 'baz' -TargetObjectName 'Buzz'
Demonstrates how to create a synonym in a different schema. Creates a synonym to the baz.Buzz
object so that it can referenced as fiz.Buzz
.
Add-Synonym -Name 'Buzz' -TargetDatabaseName 'Fizzy' -TargetObjectName 'Buzz'
Demonstrates how to create a synonym to an object in a different database.