当前位置:网站首页>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
边栏推荐
- Geoffrey Hinton:我的五十年深度学习生涯与研究心法
- depends工具查看exe和dll依赖关系
- 挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案
- Troubleshooting MySQL for update deadlock
- Deep learning compiler understanding
- Compare the audio librosa library with the Mel spectrogram in the torchaudio library
- 「杂谈」对数据分析未来的几点思考
- Rhai - Rust 的嵌入式脚本引擎
- Vulnerability recurrence ----37. Apache unomi Remote Code Execution Vulnerability (cve-2020-13942)
- How to do a good job in software system demand research? Seven weapons make it easy for you to do it
猜你喜欢

Coding officially entered Tencent conference application market!

英飞凌--GTM架构-Generic Timer Module

Digital intelligent supplier management system solution for coal industry: data driven, supplier intelligent platform helps enterprises reduce costs and increase efficiency

屏幕显示技术进化史

系统集成项目管理工程师认证高频考点:编制项目范围管理计划

What if the apple watch fails to power on? Apple watch can not boot solution!

Swin-Transformer(2021-08)

openGauss数据库源码解析系列文章—— 密态等值查询技术详解(上)

EasyNVR平台设备通道均在线,操作出现“网络请求失败”是什么原因?
![Delete duplicate elements in the sorting linked list ii[unified operation of linked list nodes --dummyhead]](/img/dd/7df8f11333125290b4b30183cfff64.png)
Delete duplicate elements in the sorting linked list ii[unified operation of linked list nodes --dummyhead]
随机推荐
基于UDP协议设计的大文件传输软件
Distributed transaction
一点比较有意思的模块
屏幕显示技术进化史
Swin-transformer --relative positional Bias
Detailed single case mode
金融服务行业SaaS项目管理系统解决方案,助力企业挖掘更广阔的增长服务空间
Rust 如何实现依赖注入?
The online procurement system of the electronic components industry accurately matches the procurement demand and leverages the digital development of the electronic industry
[零基础学IoT Pwn] 环境搭建
音频 librosa 库 与 torchaudio 库中 的 Mel- spectrogram 进行对比
3.10 haas506 2.0开发教程-example-TFT
Is it safe to open a mobile stock account? Is it reliable?
Dlib library for face key point detection (openCV Implementation)
Entry node of link in linked list - linked list topic
Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
Four tips tell you how to use SMS to promote business sales?
CODING 正式入驻腾讯会议应用市场!
Reading notes of "high EQ means being able to talk"
Do you really understand the persistence mechanism of redis?