Събитие
31.03, 23 ч. - 2.04, 23 ч.
Най-голямото събитие за обучение по SQL, Fabric и Power BI. 31 март – 2 април. Използвайте код FABINSIDER, за да спестите $400.
Регистрирайте се днесТози браузър вече не се поддържа.
Надстройте до Microsoft Edge, за да се възползвате от най-новите функции, актуализации на защитата и техническа поддръжка.
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
This article describes how to add new columns to a table in SQL Server by using SQL Server Management Studio or Transact-SQL.
Using the ALTER TABLE
statement to add columns to a table automatically adds those columns to the end of the table.
If you want the columns in a specific order in the table, you must use SQL Server Management Studio. Though it isn't recommended, for more information on reordering tables, see Change Column Order in a Table.
To query existing columns, use the sys.columns object catalog view.
Requires ALTER permission on the table.
Важно
Always use the latest version of SQL Server Management Studio (SSMS).
SQL Server Management Studio (SSMS) doesn't support all data definition language (DDL) options in Azure Synapse. Use T-SQL scripts instead.
In Object Explorer, right-click the table to which you want to add columns and choose Design.
Select the first blank cell in the Column Name column.
Type the column name in the cell. The column name is a required value.
Press the TAB key to go to the Data Type cell and select a data type from the dropdown list. Data type is a required value, and is assigned the default value if you don't choose one.
Бележка
You can change the default value in the Options dialog box under Database Tools.
Continue to define any other column properties in the Column Properties tab.
Бележка
The default values for your column properties are added when you create a new column, but you can change them in the Column Properties tab.
When you're finished adding columns, from the File menu, choose Save table name.
The following example adds two columns to the table dbo.doc_exa
.
ALTER TABLE dbo.doc_exa
ADD column_b VARCHAR(20) NULL, column_c INT NULL ;
Събитие
31.03, 23 ч. - 2.04, 23 ч.
Най-голямото събитие за обучение по SQL, Fabric и Power BI. 31 март – 2 април. Използвайте код FABINSIDER, за да спестите $400.
Регистрирайте се днесОбучение
Модул
Create and manage columns within a table in Microsoft Dataverse - Training
Learn how to create and manage table columns in Dataverse.
Сертифициране
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.
Документация
Delete columns from a table - SQL Server
Learn how to delete table columns in the SQL Server Database Engine with SQL Server Management Studio or Transact-SQL.
This article shows you how to modify columns using SQL Server Management Studio and Transact-SQL.
Specify default values for columns - SQL Server
Specify a default value that is entered into the table column, with SQL Server Management Studio or Transact-SQL.