SqlServer如何給表新增新的字段以及字段注釋

2021-10-01 05:31:06 字數 492 閱讀 9546

use 資料庫名

alter table 表名 add 欄位名  型別  預設值  是否為空;

exec sp_addextendedproperty n'ms_description', n'注釋內容', n'schema', n'dbo',n'table', n'表名', n'column', n'欄位名';

use [gameagent]

alter table [gameagent].[dbo].[charge_consume]  add  card_consume  int  default(0)   not null;

exec sp_addextendedproperty n'ms_description', n'房卡消耗', n'schema', n'dbo',n'table', n'charge_consume', n'column', n'card_consume';

建議設定值不為空,且要給預設值;

新加的字段在表中的位置似乎沒法自定義。

Sqlserver給表名和列名新增注釋

一 表注釋 1 新增 固定寫法 exec sys.sp addextendedproperty name n ms description level1type n table level0type n schema level0name n dbo 自定義 value n 注釋內容 level1n...

SQLserver 如何給表新建觸發器

sql set ansi nulls on goset quoted identifier on gocreate trigger update xmsx after update xsxxb xm on dbo.xsxxb after update 在更新資料時對錶中資料進行更新 asbegin ...

Mysql 給表新增字段

第一步 drop table if exists city create table city id int 11 not null auto increment,name char 35 not null default countrycode char 3 not null default di...