当前位置:网站首页>sql语句修改字段类型「建议收藏」
sql语句修改字段类型「建议收藏」
2022-07-01 09:41:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
修改字段名:
sp_rename ‘表名.原字段名’,’表名.新字段名’ 例如我想把Card_Info表里面的OnDate改为Date: sp_rename ‘Card_Info.OnDate’,’Card_Info.Date’
修改数据类型:
alter table 表名 alter column 列名 数据类型 例如我想把Card_Info表里面的Time数据类型由time(7)改为time(0) alter table Card_Info alter column Time time(0)
修改字段名为非空:
ALTER TABLE 表 ALTER COLUMN [字段名] 字段类型 NOT NULL 如我想把Card_Info表里面的Time数据类型改为允许为空: alter table Card_Info alter column Time time(0) null 改为非空就是后面改为not null;
增加字段名:
通用式:alter table [表名] add [字段名] 字段属性 例如我想在CancelCard_Info表里面加一个IsCheck是否结账名; alter table CancelCard_Info add IsCheck varchar(10)
以前想修改字段类型的话我直接把数据库某一个表给删掉重新添加,但是学习了这些sql语句后再去修改就会变得方便很多。以上几个修改方法我都试过了;很有用的sql语句;
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/131771.html原文链接:https://javaforall.cn
边栏推荐
猜你喜欢
Meituan P4 carefully collated microservice system architecture design manual to see the world of microservice architecture
Flinkv1.13实现金融反诈骗案例
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
JS scope chain and closure
JS prototype chain
Import and export of power platform platform sharepointlist
谁拥有穿越周期的眼光?
JS原型链
年薪100万,在北上广深买的起房子吗?
2022.02.15_ Daily question leetcode six hundred and ninety
随机推荐
奇怪,为什么ArrayList初始化容量大小为10?
Meituan P4 carefully collated microservice system architecture design manual to see the world of microservice architecture
delete和delete[]引发的问题
JS use toString to distinguish between object and array
js变量提升(hoisting)
谁拥有穿越周期的眼光?
JS prototype chain
SQL learning notes (01) - basic knowledge of database
Concept of digital currency
Learning practice: comprehensive application of cycle and branch structure (II)
Scratch big fish eat small fish Electronic Society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
【leetcode】287. Find duplicates
IPv6 learning notes
js valueOf 与 toString 区别
[unity shader] substitution of bool type in the property definition
富文本实现插值
Get the list of a column in phpexcel get the letters of a column
Tearful eyes, it's not easy to change jobs. Three rounds of interviews, four hours of soul torture
手指点击屏幕就模拟进入F11进入全屏
短路运算符惰性求值