mssql sqlserver 给已存在表添加新的字段及字段备注的方法

摘要:
下文讲述向已存在表上添加新字段及字段备注的方法,如下所示:
实验环境:sql server 2008 r2

1. 添加新字段及字段备注的语法
use 数据库名
alter table 表名 add 字段名 类型 默认值 是否为空;
exec sp_addextendedproperty n’ms_description’, n’注释内容’, n’schema’, n’dbo’,n’table’, n’表名’, n’column’, n’字段名’;

2.添加新字段及字段备注举例应用

use [maomao365]
alter table [maomao365].[dbo].[testtable] add qty int default 1 not null;
---为表testtable新增列qty,并设置数据类型为int型和默认值0

exec sp_addextendedproperty n'ms_description', n'领料数', n'schema', n'dbo',n'table', n'testtable', n'column', n'qty';
---为列qty添加说明

 

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐