当前位置:网站首页>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
边栏推荐
- 持续进阶,软通动力稳步推动云智能战略
- 122. Thread class thread method summary; Why is the thread start method start () not run ()?
- PHP string to binary conversion
- SQL学习笔记(04)——数据更新、查询操作
- In terms of use
- 京东与腾讯续签三年战略合作协议;起薪涨至26万元!韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条...
- Huawei accounts work together at multiple ends to create a better internet life
- The stock position building rate of global funds and asset management reached a new low in 15 years
- 全球基金和资管的股票建仓率达到15年内新低
- PHP code audit and File Inclusion Vulnerability
猜你喜欢

PR training notes

Learning practice: comprehensive application of cycle and branch structure (II)

睡了二哥。。。

IPv6 learning notes

主流实时流处理计算框架Flink初体验

炒币,亏了1000万。

计网01-物理层

The stock position building rate of global funds and asset management reached a new low in 15 years

Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"

电脑USB、HDMI、DP各种接口及速度
随机推荐
Some tools used in embedded development
How to realize the usage of connecting multiple databases in idel
Network partition notes
JS use toString to distinguish between object and array
Unity tips for reducing the amount of code -- empty protection extension
Implementation and application of queue
奇怪,为什么ArrayList初始化容量大小为10?
Dotnet console uses microsoft Maui. Getting started with graphics and skia
ES6 decoupling top-level objects from windows
Using closures to implement private variables
架构实战营 模块九:设计电商秒杀系统
CSDN's one-stop cloud service is open for internal testing, and new and old users are sincerely invited to grab the fresh
PHP 字符串与二进制相互转换
[untitled]
PR training notes
Spark's action operator
华为帐号多端协同,打造美好互联生活
Meituan P4 carefully collated microservice system architecture design manual to see the world of microservice architecture
123. how to stop a thread?
ES6-const本质与完全不可改实现(Object.freeze)