当前位置:网站首页>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
边栏推荐
猜你喜欢

Vulnerability recurrence ----- 35. Uwsgi PHP directory traversal vulnerability (cve-2018-7490)

Cloud Native Landing Practice Using rainbond for extension dimension information

Swin-transformer --relative positional Bias

Leader: who can use redis expired monitoring to close orders and get out of here!

一点比较有意思的模块

ONEFLOW source code parsing: automatic inference of operator signature

TCP packet sticking problem

When selecting smart speakers, do you prefer "smart" or "sound quality"? This article gives you the answer

秉持'家在中国'理念 2022 BMW儿童交通安全训练营启动

Apple Watch无法开机怎么办?苹果手表不能开机解决方法!
随机推荐
Rust 如何实现依赖注入?
What if the apple watch fails to power on? Apple watch can not boot solution!
Multipass Chinese document - setting graphical interface
Sword finger offer 16 Integer power of numeric value
PC wechat multi open
使用excel快速生成sql语句
「经验」我对用户增长的理解『新用户篇』
Where do the guests come from
Courage to be hated: Adler's philosophy class: the father of self inspiration
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
php利用队列解决迷宫问题
Multipass中文文档-设置图形界面
Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
TCP粘包问题
Ambient light and micro distance detection system based on stm32f1
Redis - persistent RDB and persistent AOF
How to use AI technology to optimize the independent station customer service system? Listen to the experts!
Can go struct in go question bank · 15 be compared?
mysql for update 死锁问题排查
Glacier teacher's book