当前位置:网站首页>mysql修改数据类型_MySQL修改字段类型[通俗易懂]
mysql修改数据类型_MySQL修改字段类型[通俗易懂]
2022-06-30 17:46:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
mysql> alter table 表名 modify column 字段名 类型。数据库中address表 city字段是varchar(30),修改类型可以用(谨慎修改类型,可能会导致原有数据出错)。
mysql> alter table address modify column city char(30);修改长度可以用(修改长度,要保证不短与已有数据,以保证原有数据不出错)mysql> alter table address modify column city varchar(50);
alter table 表名 modify column 字段名 类型;news 表里的title 字段 原来长度是 100个字符,现长度要改成130个字符。
mysql 修改字段类型:alter table news modify column title text;我发现使用这句sql也可以直接修改字段原本的类型!
通常可以写成 alter table 表名 modify column 列名 新的列的类型例如:student表中列sname的类型是char(20),现在要修改为varchar(20),SQL语句如下alter table student modify column sname varchar(20);
同时修改列名和列的数据类型的方法:通常可以写成 alter table 表名 change column 旧列名 新列名 新的列类型student表中列sname的类型是char(20),现在要修改为stuname varchar(20)alter table student change column sname stuname varchar(20);
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/132251.html原文链接:https://javaforall.cn
边栏推荐
- When selecting smart speakers, do you prefer "smart" or "sound quality"? This article gives you the answer
- LeetCode动态规划经典题(一)
- 充值满赠,IM+RTC+X 全通信服务「回馈季」开启
- OneFlow源码解析:算子签名的自动推断
- 电子元器件招标采购商城:优化传统采购业务,提速企业数字化升级
- Tide - 基于 async-std 的 Rust-web 框架
- Redis - persistent RDB and persistent AOF
- 《Go题库·15》go struct 能不能比较?
- Vulnerability recurrence ----- 35. Uwsgi PHP directory traversal vulnerability (cve-2018-7490)
- Glacier teacher's book
猜你喜欢

iCloud照片无法上传或同步怎么办?

Dlib库实现人脸关键点检测(Opencv实现)

Hospital online consultation applet source code Internet hospital source code smart hospital source code

传统微服务框架如何无缝过渡到服务网格 ASM

拓维信息使用 Rainbond 的云原生落地实践

Personally test the size of flutter after packaging APK, quite satisfied

TCP packet sticking problem

正则表达式(正则匹配)

一点比较有意思的模块

How to use AI technology to optimize the independent station customer service system? Listen to the experts!
随机推荐
《Go题库·15》go struct 能不能比较?
SaaS project management system solution for the financial service industry helps enterprises tap a broader growth service space
MRO工业品采购管理系统:赋能MRO企业采购各节点,构建数字化采购新体系
MySQL找不到mysql.sock文件的臨時解
Reading notes of "high EQ means being able to talk"
Tide - 基于 async-std 的 Rust-web 框架
AI chief architect 10-aica-lanxiang, propeller frame design and core technology
如何做好软件系统的需求调研,七种武器让你轻松搞定
Leader: who can use redis expired monitoring to close orders and get out of here!
浏览器窗口切换激活事件 visibilitychange
Swin-transformer --relative positional Bias
rust配置国内源
一文详解|Go 分布式链路追踪实现原理
mysql for update 死锁问题排查
英飞凌--GTM架构-Generic Timer Module
挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案
Where do the guests come from
电子元器件招标采购商城:优化传统采购业务,提速企业数字化升级
Small program container technology to promote the operation efficiency of the park
Compare the audio librosa library with the Mel spectrogram in the torchaudio library