当前位置:网站首页>SQL statement modify field type "suggestions collection"

SQL statement modify field type "suggestions collection"

2022-07-01 09:50:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm your friend, Quan Jun .

Modify field name :

sp_rename ‘ Table name . Original field name ’,’ Table name . new field name ’ For example, I want to put Card_Info Inside the watch OnDate Change it to Date: sp_rename ‘Card_Info.OnDate’,’Card_Info.Date’

Change data type :

alter table Table name alter column Name data type For example, I want to put Card_Info Inside the watch Time The data type consists of time(7) Change it to time(0) alter table Card_Info alter column Time time(0)

Modify the field name to be non empty :

ALTER TABLE surface ALTER COLUMN [ Field name ] Field type NOT NULL If I want to Card_Info Inside the watch Time The data type is changed to allow null : alter table Card_Info alter column Time time(0) null If it is changed to non empty, it will be changed to not null;

Add field name :

Universal :alter table [ Table name ] add [ Field name ] Field properties For example, I want to be in CancelCard_Info Add one in the table IsCheck Closing name ; alter table CancelCard_Info add IsCheck varchar(10)

Before, if I wanted to modify the field type, I directly deleted a table in the database and added it again , But I learned this sql It will be much more convenient to modify after the statement . I have tried all the above modification methods ; Very useful sql sentence ;

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/131771.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207010939143592.html