--删除表字段:
alter table wbs_statuses_home_timeline drop column wbsname;
--重命名表字段名称:
alter table wbs_statuses_update_w rename column serverwbsname to serverusername;
--新增表字段:
alter table wbs_statuses_home_timeline add CommentNum number;
--sql修改数据库表字段的数据类型
alter table 表名 alter column 列名 新的数据类型
--sql删除数据库表字段
ALTER TABLE PMSRoomStatusLog DROP COLUMN Message
--新增表字段(SQL):
alter table ActivityTags add DisplayIndex int null;
--两张表进行数据交换
insert into Activitys(ActivitysID, Title, ImageUrl, Discount, BeginTime, EndTime, ActivityUrlTypeID, ActivityUrl, DisplayIndex, GroupID, PosterTitle, PosterContent, PosterImageUrl, CustomerID, CreateBy, CreateTime, LastUpdateBy, LastUpdateTime,IsDelete)
select SimpleEventsID,Title,ImageUrl,Discount,BeginTime, EndTime,EventUrlTypeID, EventUrl,DisplayIndex,GroupID,PosterTitle, PosterContent, PosterImageUrl,
CustomerID, CreateBy,CreateTime, LastUpdateBy, LastUpdateTime, IsDelete
from SimpleEvents where IsDelete=0;
--查看表的列数
select count(*) as columNun from sysobjects a join syscolumns b
on a.id=b.id
where a.name='crs_nazh'
;with m as (
select
*,
row_number() over(partition by HotelCode,RoomNo,RoomStatus,WarnPowerTime order by RoomNo) rn
from WarnPowerInfo
)
delete m where rn > 1
DELETE t FROM (SELECT *,ROW_NUMBER()OVER(PARTITION BY test1,test2,test3,test4 ORDER BY RAND()) AS RN FROM WarnPowerInfo) AS t WHERE RN>1
alter table wbs_statuses_home_timeline drop column wbsname;
--重命名表字段名称:
alter table wbs_statuses_update_w rename column serverwbsname to serverusername;
--新增表字段:
alter table wbs_statuses_home_timeline add CommentNum number;
--sql修改数据库表字段的数据类型
alter table 表名 alter column 列名 新的数据类型
--sql删除数据库表字段
ALTER TABLE PMSRoomStatusLog DROP COLUMN Message
--新增表字段(SQL):
alter table ActivityTags add DisplayIndex int null;
--两张表进行数据交换
insert into Activitys(ActivitysID, Title, ImageUrl, Discount, BeginTime, EndTime, ActivityUrlTypeID, ActivityUrl, DisplayIndex, GroupID, PosterTitle, PosterContent, PosterImageUrl, CustomerID, CreateBy, CreateTime, LastUpdateBy, LastUpdateTime,IsDelete)
select SimpleEventsID,Title,ImageUrl,Discount,BeginTime, EndTime,EventUrlTypeID, EventUrl,DisplayIndex,GroupID,PosterTitle, PosterContent, PosterImageUrl,
CustomerID, CreateBy,CreateTime, LastUpdateBy, LastUpdateTime, IsDelete
from SimpleEvents where IsDelete=0;
--查看表的列数
select count(*) as columNun from sysobjects a join syscolumns b
on a.id=b.id
where a.name='crs_nazh'
;with m as (
select
*,
row_number() over(partition by HotelCode,RoomNo,RoomStatus,WarnPowerTime order by RoomNo) rn
from WarnPowerInfo
)
delete m where rn > 1
DELETE t FROM (SELECT *,ROW_NUMBER()OVER(PARTITION BY test1,test2,test3,test4 ORDER BY RAND()) AS RN FROM WarnPowerInfo) AS t WHERE RN>1