Udalosti
31. 3., 23 - 2. 4., 23
Najväčšia vzdelávacia udalosť pre SQL, Fabric a Power BI. 31. marec – 2. apríl. Pomocou kódu FABINSIDER ušetríte 400 USD.
Zaregistrujte saTento prehliadač už nie je podporovaný.
Inovujte na Microsoft Edge a využívajte najnovšie funkcie, aktualizácie zabezpečenia a technickú podporu.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
This article describes how to create a synonym in SQL Server by using SQL Server Management Studio or Transact-SQL.
To create a synonym in a given schema, a user must have CREATE SYNONYM permission and either own the schema or have ALTER SCHEMA permission. The CREATE SYNONYM permission is a grantable permission.
In Object Explorer, expand the database where you want to create your new view.
Right-click the Synonyms folder, then select New Synonym....
In the Add Synonym dialog box, enter the following information.
Synonym name
Type the new name you will use for this object.
Synonym schema
Type the schema of the new name you will use for this object.
Server name
Type the server instance to connect to.
Database name
Type or select the database containing the object.
Schema
Type or select the schema that owns the object.
Object type
Select the type of object.
Object name
Type the name of the object to which the synonym refers.
Connect to the Database Engine.
From the Standard bar, select New Query.
Copy and paste the following examples into the query window and select Execute.
The following example creates a synonym for an existing table in the AdventureWorks2022
database. The synonym is then used in subsequent examples.
USE tempdb;
GO
CREATE SYNONYM MyAddressType
FOR AdventureWorks2022.Person.AddressType;
GO
The following example inserts a row into the base table that is referenced by the MyAddressType
synonym.
USE tempdb;
GO
INSERT INTO MyAddressType (Name)
VALUES ('Test');
GO
The following example demonstrates how a synonym can be referenced in dynamic SQL.
USE tempdb;
GO
EXECUTE ('SELECT Name FROM MyAddressType');
GO
Udalosti
31. 3., 23 - 2. 4., 23
Najväčšia vzdelávacia udalosť pre SQL, Fabric a Power BI. 31. marec – 2. apríl. Pomocou kódu FABINSIDER ušetríte 400 USD.
Zaregistrujte saŠkolenie
Modul
Create tables, views, and temporary objects - Training
This content is a part of Create tables, views, and temporary objects.
Certifikácia
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.