晚会开场背景音乐,美女露底,两天一夜090927
表中数据行的数据插入和数据类型都是基于数据列的,学会添加数据列在开发过程中是必不可少的。
在数据表中添加一列或者多列步骤相同
1、连接数据库,选择数据表-》右键点击-》选择设计。
2、在新打开的窗口中输入中-》输入列名,数据类型,是否可空-》在下面输入列注释等属性-》点击保存按钮(或者ctrl+s)。
3、如果想在指定列前面添加数据列-》选择要指定列,右键点击-》插入数据列-》输入列名,列类型,是否可空,属性等,点击保存。
语法:alter table 数据库名.dbo.表名 add 列名 列类型 [not] null;
示例:
--添加可空数据列
alter table testss.dbo.test1 add height1 nvarchar(50) null;
--添加不可空数据列
alter table testss.dbo.test1 add height2 nvarchar(50) not null;
语法:
alter table 数据库名.dbo.表名 add 列名 列数据类型 [not] null;
execute sp_addextendedproperty n'ms_description', n'列说明', n'user', n'dbo', n'table', n'表明, n'column', n'列名';
示例:
alter table testss.dbo.test1 add height3 nvarchar(50) null;
execute sp_addextendedproperty n'ms_description', n'身高3', n'user', n'dbo', n'table', n'test1', n'column', n'height3';
语法:alter table 数据库名.dbo.表名 add 列名 int not null default 值;
示例:alter table testss.dbo.test1 add testid int not null default 1;
语法:
alter table 数据库名.dbo.表名 add 列名 列类型 not null default 值,列名 列类型 null default 值;
示例:
alter table testss.dbo.test1 add height5 int not null default 1,
height6 nvarchar(20) null default '178cm';
在生产或者开发阶段,数据列的添加建议使用t-sql脚本,方便开发和生产,且易于维护。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (上)
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (下)
网友评论